From: Harlan Stenn Date: Sat, 17 Mar 2007 20:19:52 +0000 (-0500) Subject: [Bug 798] ntpq [p typo crashes ntpdc X-Git-Tag: NTP_4_2_5P18~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72c8a9fe6104f4f0de3a093e0638ad1b2d4ba769;p=thirdparty%2Fntp.git [Bug 798] ntpq [p typo crashes ntpdc bk: 45fc4d68EPTSZNYHiGGCxqSI58JaUg --- diff --git a/ChangeLog b/ChangeLog index 5ec56005e..fa1851145 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ * [Bug 795] Moved declaration of variable to top of function. -* [Bug 798] ntpq [p typo crashes ntpq. +* [Bug 798] ntpq [p typo crashes ntpq/ntpdc. * [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/ntpdc/ntpdc.c b/ntpdc/ntpdc.c index d1c0301b9..347bb3f30 100644 --- a/ntpdc/ntpdc.c +++ b/ntpdc/ntpdc.c @@ -499,10 +499,14 @@ openhost( if (*cp == '[') { cp++; - for(i = 0; *cp != ']'; cp++, i++) - name[i] = *cp; - name[i] = '\0'; - hname = name; + for (i = 0; *cp && *cp != ']'; cp++, i++) + name[i] = *cp; + if (*cp == ']') { + name[i] = '\0'; + hname = name; + } else { + return 0; + } } /*