Re: Minor problems...

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Neal Becker
Data:  
Para: Ilya Ketris
CC: exim-users
Asunto: Re: Minor problems...
>>>>> "Ilya" == Ilya Ketris <ilya@???> writes:

    Ilya>     Let me add to it.


    Ilya>     src/readconf.c says:


    Ilya> ........
    Ilya>   if (strchr(s.nodename, '.') == NULL)
    Ilya>     {
    Ilya>     struct hostent *host = gethostbyname(s.nodename);
    Ilya>     primary_hostname = string_copy((char *)host->h_name);
    Ilya>     }
    Ilya>   else primary_hostname = string_copy(s.nodename);
    Ilya> ........


    Ilya>     What if gethostbyname fails?  You guessed it
    Ilya>     -- segmentation violation...


Ouch. If memory serves, this is my tiny contribution to exim.

The simple-minded fix:

  if (strchr(s.nodename, '.') == NULL)
    {
    struct hostent *host = gethostbyname(s.nodename);
    if (host)
      primary_hostname = string_copy((char *)host->h_name);
    else
      primary_hostname = string_copy(s.nodename);
    }
  else primary_hostname = string_copy(s.nodename);