]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Allocate memory for entry->ce_name
authorHarlan Stenn <stenn@ntp.org>
Tue, 19 Feb 2002 05:30:20 +0000 (00:30 -0500)
committerHarlan Stenn <stenn@ntp.org>
Tue, 19 Feb 2002 05:30:20 +0000 (00:30 -0500)
and remove some unnecessary code.

From: John Hay.

bk: 3c71e2ecqor4d08QUNNqkLmTKORa5Q

ntpd/ntp_intres.c

index 1cadc92811d1291d5650fdb4848db00a8de26f4e..b306ccf6f260b7998de6844444376ff074ce45e0 100644 (file)
@@ -491,9 +491,11 @@ findhostaddr(
                        msyslog(LOG_INFO, "findhostaddr: Resolving %s>",
                                stoa(&entry->peer_store));
 #endif
+               entry->ce_name = emalloc(MAXHOSTNAMELEN);
                error = getnameinfo((const struct sockaddr *)&entry->peer_store,
                                   SOCKLEN(&entry->peer_store),
-                                  (char*)&entry->ce_name, sizeof(entry->ce_name), NULL, 0, 0);
+                                  (char *)&entry->ce_name, MAXHOSTNAMELEN,
+                                  NULL, 0, 0);
        }
 
        if (error != 0) {
@@ -516,10 +518,6 @@ findhostaddr(
                if (debug > 2)
                        msyslog(LOG_INFO, "findhostaddr: address resolved.");
 #endif
-               s = strlen(hp->h_name) + 1;
-               cp = (char *)emalloc(s);
-               strcpy(cp, hp->h_name);
-               entry->ce_name = cp;
        }
                   
        return (1);