bin/74140: ntpdate(8): ntpdate does not try all IPs for a host

Takamichi Tateoka tate at tateoka.org
Tue Jan 1 17:40:03 PST 2008


The following reply was made to PR bin/74140; it has been noted by GNATS.

From: "Takamichi Tateoka" <tate at tateoka.org>
To: <bug-followup at FreeBSD.org>, <antiduh at csh.rit.edu>
Cc: <tate at tateoka.org>
Subject: Re: bin/74140: ntpdate(8): ntpdate does not try all IPs for a host
Date: Wed, 2 Jan 2008 09:58:01 +0900

 1jM MIME `.L}`p[g bZ[WE7B
 
 ------=_NextPart_000_0001_01C84D25.F65A9780
 Content-Type: text/plain;
 	charset="us-ascii"
 Content-Transfer-Encoding: 7bit
 
 I create a small patch.  It simply tries all of unknown addresses.
 --
 Takamichi Tateoka
 
 
 
 ------=_NextPart_000_0001_01C84D25.F65A9780
 Content-Type: application/octet-stream;
 	name="ntpdate.c.diff"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
 	filename="ntpdate.c.diff"
 
 *** contrib/ntp/ntpdate/ntpdate.c.DIST	Mon Dec  6 23:33:29 2004=0A=
 --- contrib/ntp/ntpdate/ntpdate.c	Wed Jan  2 09:39:57 2008=0A=
 ***************=0A=
 *** 1325,1331 ****=0A=
   {=0A=
   	register struct server *server;=0A=
           /* Address infos structure to store result of getaddrinfo */=0A=
 !         struct addrinfo *addrResult;=0A=
           /* Address infos structure to store hints for getaddrinfo */=0A=
           struct addrinfo hints;=0A=
           /* Error variable for getaddrinfo */=0A=
 --- 1325,1331 ----=0A=
   {=0A=
   	register struct server *server;=0A=
           /* Address infos structure to store result of getaddrinfo */=0A=
 !         struct addrinfo *addrResult, *addrp;=0A=
           /* Address infos structure to store hints for getaddrinfo */=0A=
           struct addrinfo hints;=0A=
           /* Error variable for getaddrinfo */=0A=
 ***************=0A=
 *** 1356,1377 ****=0A=
           }=0A=
   #endif=0A=
   =0A=
 ! 	server =3D (struct server *)emalloc(sizeof(struct server));=0A=
 ! 	memset((char *)server, 0, sizeof(struct server));=0A=
 ! =0A=
 !         /* For now we only get the first returned server of the =
 addrinfo list */=0A=
 !         memset(&(server->srcadr), 0, sizeof(struct sockaddr_storage));=0A=
 !         memcpy(&(server->srcadr), addrResult->ai_addr, =
 addrResult->ai_addrlen);=0A=
 ! 	server->event_time =3D ++sys_numservers;=0A=
 ! 	if (sys_servers =3D=3D NULL)=0A=
   		sys_servers =3D server;=0A=
 ! 	else {=0A=
   		struct server *sp;=0A=
 ! =0A=
   		for (sp =3D sys_servers; sp->next_server !=3D NULL;=0A=
   		     sp =3D sp->next_server) ;=0A=
   		sp->next_server =3D server;=0A=
   	}=0A=
   }=0A=
   =0A=
   =0A=
 --- 1356,1379 ----=0A=
           }=0A=
   #endif=0A=
   =0A=
 ! 	for (addrp =3D addrResult; addrp !=3D NULL; addrp =3D addrp->ai_next){=0A=
 ! 	    server =3D (struct server *)emalloc(sizeof(struct server));=0A=
 ! 	    memset((char *)server, 0, sizeof(struct server));=0A=
 ! =0A=
 ! 	    memset(&(server->srcadr), 0, sizeof(struct sockaddr_storage));=0A=
 ! 	    memcpy(&(server->srcadr), addrp->ai_addr, addrp->ai_addrlen);=0A=
 ! 	    server->event_time =3D ++sys_numservers;=0A=
 ! 	    if (sys_servers =3D=3D NULL)=0A=
   		sys_servers =3D server;=0A=
 ! 	    else {=0A=
   		struct server *sp;=0A=
 ! 		=0A=
   		for (sp =3D sys_servers; sp->next_server !=3D NULL;=0A=
   		     sp =3D sp->next_server) ;=0A=
   		sp->next_server =3D server;=0A=
 + 	    }=0A=
   	}=0A=
 + 	freeaddrinfo(addrResult);=0A=
   }=0A=
   =0A=
   =0A=
 
 ------=_NextPart_000_0001_01C84D25.F65A9780--
 
 
 


More information about the freebsd-bugs mailing list