[ntp:bk-ntp-dev-send] BitKeeper diffs

Harlan Stenn stenn at deacon.udel.edu
Sat Apr 2 23:51:37 UTC 2011


#### ChangeSet ####
2011-04-02 06:32:52+00:00, davehart at shiny.ad.hartbrothers.com
  [Bug 1874] ntpq -c "rv 0 sys_var_list" empty.

==== ChangeLog ====
2011-04-02 06:32:48+00:00, davehart at shiny.ad.hartbrothers.com +1 -0
  [Bug 1874] ntpq -c "rv 0 sys_var_list" empty.

--- 1.828/ChangeLog	2011-03-31 14:16:43 -04:00
+++ 1.829/ChangeLog	2011-04-02 02:32:48 -04:00
@@ -1,3 +1,4 @@
+* [Bug 1874] ntpq -c "rv 0 sys_var_list" empty.
 (4.2.7p143) 2011/03/31 Released by Harlan Stenn <stenn at ntp.org>
 * [Bug 1732] ntpd ties up CPU on disconnected USB refclock.
 * [Bug 1861] tickadj build failure using uClibc.

==== ntpd/ntp_control.c ====
2011-04-02 06:32:48+00:00, davehart at shiny.ad.hartbrothers.com +27 -44
  [Bug 1874] ntpq -c "rv 0 sys_var_list" empty.

--- 1.164/ntpd/ntp_control.c	2011-03-19 12:38:07 -04:00
+++ 1.165/ntpd/ntp_control.c	2011-04-02 02:32:48 -04:00
@@ -307,7 +307,7 @@ static const struct ctl_proc control_cod
 #define	CC_FUDGEVAL2	10
 #define	CC_FLAGS	11
 #define	CC_DEVICE	12
-#define CC_VARLIST	13
+#define	CC_VARLIST	13
 #define	CC_MAXCODE	CC_VARLIST
 
 /*
@@ -1648,17 +1648,15 @@ ctl_putsys(
 {
 	l_fp tmp;
 	char str[256];
-	char buf[CTL_MAX_DATA_LEN];
 	u_int u;
 	double kb;
 	double dtemp;
-	char *s, *t, *be;
 	const char *ss;
-	int i;
+	size_t len;
+	int firstvarname;
 	const struct ctl_var *k;
 #ifdef AUTOKEY
 	struct cert_info *cp;
-	char cbuf[256];
 #endif	/* AUTOKEY */
 #ifdef KERNEL_PLL
 	static struct timex ntx;
@@ -1800,54 +1798,39 @@ ctl_putsys(
 		break;
 
 	case CS_VARLIST:
-		s = buf;
-		be = buf + sizeof(buf);
-		if (strlen(sys_var[CS_VARLIST].text) + 4 > sizeof(buf))
-			break;	/* really long var name */
-
-		snprintf(s, sizeof(buf), "%s=\"",
+		snprintf(str, sizeof(str), "%s=\"",
 			 sys_var[CS_VARLIST].text);
-		s += strlen(s);
-		t = s;
+		ctl_putdata(str, strlen(str), TRUE);
+
+		firstvarname = TRUE;
 		for (k = sys_var; !(EOV & k->flags); k++) {
 			if (PADDING & k->flags)
 				continue;
-			i = strlen(k->text);
-			if (s + i + 1 >= be)
-				break;
-
-			if (s != t)
-				*s++ = ',';
-			memcpy(s, k->text, i);
-			s += i;
+			len = strlen(k->text);
+			if (0 == len)
+				continue;
+			if (!firstvarname)
+				ctl_putdata(",", 1, TRUE);
+			else
+				firstvarname = FALSE;
+			ctl_putdata(k->text, len, TRUE);
 		}
 
 		for (k = ext_sys_var; k && !(EOV & k->flags); k++) {
 			if (PADDING & k->flags)
 				continue;
-
-			ss = k->text;
-			if (NULL == ss)
+			if (NULL == k->text)
 				continue;
-
-			while (*ss != '\0' && *ss != '=')
-				ss++;
-			i = ss - k->text;
-			if (s + i + 1 >= be)
-				break;
-
-			if (s != t)
-				*s++ = ',';
-			memcpy(s, k->text, (unsigned)i);
-			s += i;
+			ss = strchr(k->text, '=');
+			if (NULL == ss)
+				len = strlen(k->text);
+			else
+				len = ss - k->text;
+			ctl_putdata(",", 1, TRUE);
+			ctl_putdata(k->text, len, TRUE);
 		}
-		if (s + 2 >= be)
-			break;
 
-		*s++ = '"';
-		*s = '\0';
-
-		ctl_putdata(buf, (unsigned)(s - buf), 0);
+		ctl_putdata("\"", 1, TRUE);
 		break;
 
 	case CS_TAI:
@@ -2243,10 +2226,10 @@ ctl_putsys(
 
 	case CS_CERTIF:
 		for (cp = cinfo; cp != NULL; cp = cp->link) {
-			snprintf(cbuf, sizeof(cbuf), "%s %s 0x%x",
+			snprintf(str, sizeof(str), "%s %s 0x%x",
 			    cp->subject, cp->issuer, cp->flags);
-			ctl_putstr(sys_var[CS_CERTIF].text, cbuf,
-			    strlen(cbuf));
+			ctl_putstr(sys_var[CS_CERTIF].text, str,
+			    strlen(str));
 			ctl_putfs(sys_var[CS_REVTIME].text, cp->last);
 		}
 		break;

==== ntpq/ntpq.c ====
2011-04-02 06:32:49+00:00, davehart at shiny.ad.hartbrothers.com +10 -10
  [Bug 1874] ntpq -c "rv 0 sys_var_list" empty.

--- 1.133/ntpq/ntpq.c	2011-03-05 17:35:33 -05:00
+++ 1.134/ntpq/ntpq.c	2011-04-02 02:32:49 -04:00
@@ -303,7 +303,7 @@ struct xcmd builtins[] = {
 #define	MAXLINE		512		/* maximum line length */
 #define	MAXTOKENS	(1+MAXARGS+2)	/* maximum number of usable tokens */
 #define	MAXVARLEN	256		/* maximum length of a variable name */
-#define	MAXVALLEN	400		/* maximum length of a variable value */
+#define	MAXVALLEN	2048		/* maximum length of a variable value */
 #define	MAXOUTLINE	72		/* maximum length of an output line */
 #define SCREENWIDTH	76		/* nominal screen width in columns */
 
@@ -2585,10 +2585,10 @@ atoascii(
 	size_t out_octets
 	)
 {
-	register const u_char *	pchIn;
-		 const u_char *	pchInLimit;
-	register u_char *	pchOut;
-	register u_char		c;
+	const u_char *	pchIn;
+	const u_char *	pchInLimit;
+	u_char *	pchOut;
+	u_char		c;
 
 	pchIn = (const u_char *)in;
 	pchInLimit = pchIn + in_octets;
@@ -2761,7 +2761,7 @@ nextvar(
 	if ('"' == *np) {
 		do {
 			np++;
-		} while (np < cpend && '"' != *np && '\r' != *np);
+		} while (np < cpend && '"' != *np);
 		if (np < cpend && '"' == *np)
 			np++;
 	} else {
@@ -2769,8 +2769,8 @@ nextvar(
 			np++;
 	}
 	len = np - cp;
-	if (np >= cpend || len >= sizeof(value) ||
-	    (',' != *np && '\r' != *np))
+	if (np > cpend || len >= sizeof(value) ||
+	    (np < cpend && ',' != *np && '\r' != *np))
 		return 0;
 	memcpy(value, cp, len);
 	/*
@@ -3049,7 +3049,7 @@ cookedprint(
 	l_fp lfparr[8];
 	char b[12];
 	char bn[2 * MAXVARLEN];
-	char bv[2 * MAXVARLEN];
+	char bv[2 * MAXVALLEN];
 
 	UNUSED_ARG(datatype);
 
@@ -3146,7 +3146,7 @@ cookedprint(
 
 		if (output_raw != 0) {
 			atoascii(name, MAXVARLEN, bn, sizeof(bn));
-			atoascii(value, MAXVARLEN, bv, sizeof(bv));
+			atoascii(value, MAXVALLEN, bv, sizeof(bv));
 			if (output_raw != '*') {
 				len = strlen(bv);
 				bv[len] = output_raw;


More information about the bk-ntp-dev-send mailing list