bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] Re: getaddrinfo


From: Bruno Haible
Subject: Re: [Bug-gnulib] Re: getaddrinfo
Date: Tue, 9 Nov 2004 12:19:39 +0100
User-agent: KMail/1.5

Hi Simon,

A few comments.

> +#ifndef      GETADDRINFO_H
> +# define GETADDRINFO_H

Tabs inside #ifndef statements. Argh, why this cruelty?

> +#include <gettext.h>

I'd suggest #include "gettext.h", so that
  1. the Makefile doesn't need a -I. for gettext.h to be found,
  2. people are not misled into thinking that gettext.h were a public
     header file.

> +  if (hints &&

GNU coding style (section "Formatting Your Source Code") recommends
to put the operator && into the next line.

> +    case PF_INET6:

Can you protect this with  #if HAVE_IPV6, to avoid compilation errors
on hosts that don't support IPv6 sockets? You find an autoconf macro for
HAVE_IPV6 in ...

> +     memcpy (&sinp->sin_addr, he->h_addr_list[0], he->h_length);

I'm a bit worried that this could overwrite innocent memory if the
gethostbyname() function has returned semantically incorrect data.
I'd add a safety check here before the memcpy:

        if (he->h_length != sizeof (sinp->sin_addr))
          abort ();

> +     tmp->ai_addrlen = sizeof (sin);

'sin' is not a defined variable.

> +      free (cur);

As Paul already noted, a memory leak:
    free (cur->ai_addr);
is missing here.

> +values[] =
> +  {
> +    { EAI_ADDRFAMILY, N_("Address family for hostname not supported") },

This table has no entry for EAI_OVERFLOW; it would be worth providing such
an entry in comments, with an explanatory comment that EAI_OVERFLOW is not
used.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]