[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: correctness of libares patch



 First I moved this to debian-hurd where it should be.  Second, please use
your proper email address when writing to the mailling list.  I'm sending this
three times because I don't know where I should be sending to.

 Ok, now onto the patch

--- Morten Poulsen <morten-hurdNOSPAM@afdelingp.dk> wrote:
> Hi,
> 
> I was reading the libares-patch at
> http://hurd.dyndns.org/patches/libares.patch yesterday, and found some
> code I think is incorrect. One of the lines goes like this
> 
> hostname = (char*)realloc(hostname,sizeof(hostname)*2);
> 
> The idea - i think - is to realloc() twice the space previously
> allocated. Does that work? Isn't sizeof(hostname) always sizeof(char *)
> no matter how much allocated space it points to?

 You are right.

> I've made a new version of the patch at
> http://www.afdelingp.dk/files/patch-libares-1.1.1.diff - I hope it's
> useful.

 Your patch is almost correct.  I don't think errno is set to 0 when
gethostname
is successful, so if gethostname fails once, the loop will loop infinitly.
It would be better to use if (hostret == -1 && errno == ENAMETOOLONG).

 As for style, it seems the author is using the GNU coding style[1], so you
should use this as well.  The only thing I noticed where you didn't follow
the GNU style is with if (...), GNU has no spaces after a '(' and no space 
before a ')', so if's should be if (!hostname) instead of if ( !hostname )

> Happy hacking,
> Morten
> 
> -- 
> Morten Poulsen <morten-hurdNOSPAM@afdelingp.dk>
> 

 Once you have taken care of the infinite you should submit this patch to the
Debian BTS.  Just send an email to 112991@bugs.debian.org with the patch
included in the email, i.e. not a link to the patch.

[1] http://www.gnu.org/prep/standards_toc.html

=====
James Morrison
   University of Waterloo
   Computer Science - Digital Hardware
   2B
http://hurd.dyndns.org

Anyone referring to this as 'Open Source' shall be eaten by a GNU

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



Reply to: