bug-ddd
[Top][All Lists]
Advanced

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

potential bug in ddd/hostname.C


From: Neil Horman
Subject: potential bug in ddd/hostname.C
Date: Fri, 21 Jun 2002 08:56:57 -0400

Hello-
I think I've found a bug in hostname.C. I've included the patch that I used to fix the problem. I'm afraid I don't have the .log file handy to submit to you to, sorry. Anywho, in version 3.3 (and probably 3.3.1) of ddd, in the hostname file, there is a call to gethostbyname, the return data of which is interrogated for the systems hostname and aliases. On line 165 the h_aliases array is parsed, starting at entry zero. Accroding to the gethostbyname man page, the h_aliases value points to a null terminated list of aliases for the supplied host. It appears that if there are no aliases for a given host (such as in our environment here), this pointer is simply NULL. the aforementiond array parsing on 165 resutls in a segfault in this case. The included patch fixes that. If you have any questions, or need information regarding our environment, please don't hesitate to write. Thanks a bunch!

Regards,
Neil Horman

--
/******************************************************************
*Neil Horman
*Software Engineer
*LVL7 Systems
*13000 Weston Pkwy.
*Cary, NC 27513
*(919)-865-2915
*nhorman@lvl7.com
*PGP keyID 0xB5E1020A
*http://www.keyserver.net/en
*******************************************************************/
--- hostname.C  Mon Dec 11 07:21:48 2000
+++ /home/nhorman/hostname.C    Fri Jun 21 08:43:33 2002
@@ -160,9 +160,12 @@
            most_qualified_host = (char *)h->h_name;
 
        // Try aliases
-       for (int i = 0; h->h_aliases[i] != 0; i++)
-           if (dots(h->h_aliases[i]) > dots(most_qualified_host))
-               most_qualified_host = h->h_aliases[i];
+        if(h->aliases)
+        { 
+           for (int i = 0; h->h_aliases[i] != 0; i++)
+               if (dots(h->h_aliases[i]) > dots(most_qualified_host))
+                   most_qualified_host = h->h_aliases[i];
+        }
 
        if (dots(most_qualified_host) == 0)
        {

reply via email to

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