From: Harlan Stenn Date: Sat, 17 Mar 2007 09:53:50 +0000 (-0500) Subject: [Bug 798] ntpq [p typo crashes ntpq X-Git-Tag: NTP_4_2_5P17~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2fa3874e59e6935bc854ee0261929539c6bebaa;p=thirdparty%2Fntp.git [Bug 798] ntpq [p typo crashes ntpq bk: 45fbbaaeI5ZowcVlY9P-CI5a9_Mb8w --- diff --git a/ChangeLog b/ChangeLog index e27aaa52b..9a3877ecd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 798] ntpq [p typo crashes ntpq. * [Bug 786] Fix refclock_bancomm.c on Solaris. * [Bug 789] Fix multicast client crypto authentication. * [Bug 774] parsesolaris.c does not compile under the new Solaris. diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c index 41192f4bf..23e0bef7a 100644 --- a/ntpq/ntpq.c +++ b/ntpq/ntpq.c @@ -662,12 +662,16 @@ openhost( cp = hname; - if(*cp == '[') { + if (*cp == '[') { cp++; - for(i = 0; *cp != ']'; cp++, i++) + for (i = 0; *cp && *cp != ']'; cp++, i++) name[i] = *cp; - name[i] = '\0'; - hname = name; + if (*cp == ']') { + name[i] = '\0'; + hname = name; + } else { + return 0; + } } /*