bug-inetutils
[Top][All Lists]
Advanced

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

[bug-inetutils] fix for: 1.4.2 rshd.c misuses gethostbyaddr


From: Andrew Klossner
Subject: [bug-inetutils] fix for: 1.4.2 rshd.c misuses gethostbyaddr
Date: Fri, 19 Mar 2004 15:47:31 -0800

gethostbyaddr returns a pointer to a static, so you can only use the
value until the next call to gethostbyaddr.  rshd.c:main calls it and
tries to use the result after a subsequent calls to localdomain(),
which calls localhost(), which can call gethostbyaddr.

Here's the fix:

*** inetutils-1.4.2/rshd/old-rshd.c     Wed Dec 11 04:38:00 2002
--- inetutils-1.4.2/rshd/rshd.c Fri Mar 19 15:35:49 2004
***************
*** 463,474 ****
  #endif
        if (check_all || local_domain (hp->h_name))
          {
!           char *remotehost = (char *) alloca (strlen (hp->h_name) + 1);
            if (! remotehost)
              errorstr = "Out of memory\n";
            else
              {
!               strcpy (remotehost, hp->h_name);
                errorhost = remotehost;
                hp = gethostbyname (remotehost);
                if (hp == NULL)
--- 463,474 ----
  #endif
        if (check_all || local_domain (hp->h_name))
          {
!           char *remotehost = (char *) alloca (strlen (hostname) + 1);
            if (! remotehost)
              errorstr = "Out of memory\n";
            else
              {
!               strcpy (remotehost, hostname);
                errorhost = remotehost;
                hp = gethostbyname (remotehost);
                if (hp == NULL)




reply via email to

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