Re: Minor problems...

Top Page
Delete this message
Reply to this message
Author: Neal Becker
Date:  
To: Ilya Ketris
CC: exim-users
Subject: 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);