From: Harlan Stenn Date: Tue, 19 Feb 2002 05:30:20 +0000 (-0500) Subject: Allocate memory for entry->ce_name X-Git-Tag: NTP_4_1_73~189 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=33d46c1da1f321a106d2dcdc7ea0517727b3028f;p=thirdparty%2Fntp.git Allocate memory for entry->ce_name and remove some unnecessary code. From: John Hay. bk: 3c71e2ecqor4d08QUNNqkLmTKORa5Q --- diff --git a/ntpd/ntp_intres.c b/ntpd/ntp_intres.c index 1cadc92811..b306ccf6f2 100644 --- a/ntpd/ntp_intres.c +++ b/ntpd/ntp_intres.c @@ -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);