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:
> 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
Your patch is almost correct. I don't think errno is set to 0 when
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, 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 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 email@example.com with the patch
included in the email, i.e. not a link to the patch.
University of Waterloo
Computer Science - Digital Hardware
Anyone referring to this as 'Open Source' shall be eaten by a GNU
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.