From: Juergen Perlinger Date: Sun, 21 Aug 2016 07:29:00 +0000 (+0200) Subject: [Bug 3100] ntpq can't retrieve daemon_version X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c7ef7e082c7286dfc277c8be10c53ea25739115;p=thirdparty%2Fntp.git [Bug 3100] ntpq can't retrieve daemon_version (extended sysvar lookup bug, introduced with fix for bug 3008) bk: 57b9583c4ZJTTde3dC8E5v-eiu1xjA --- diff --git a/ChangeLog b/ChangeLog index 0805467dc..008b9c9f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +--- +* [Bug 3100] ntpq can't retrieve daemon_version + - fixed extended sysvar lookup (bug introduced with bug 3008 fix) + --- (4.2.8p8) 2016/06/02 Released by Harlan Stenn diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index 07b5697f1..acfb3b643 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -3158,15 +3158,21 @@ ctl_getitem( for (v = var_list; !(EOV & v->flags); ++v) if (!(PADDING & v->flags)) { - /* check if the var name matches the buffer */ + /* Check if the var name matches the buffer. The + * name is bracketed by [reqpt..tp] and not NUL + * terminated, and it contains no '=' char. The + * lookup value IS NUL-terminated but might + * include a '='... We have to look out for + * that! + */ const char *sp1 = reqpt; const char *sp2 = v->text; - - while ((sp1 != tp) && *sp2 && (*sp1 == *sp2)) { + + while ((sp1 != tp) && (*sp1 == *sp2)) { ++sp1; ++sp2; } - if (sp1 == tp && !*sp2) + if (sp1 == tp && (*sp2 == '\0' || *sp2 == '=')) break; }