From: Dave Hart Date: Sat, 8 Jan 2011 20:34:39 +0000 (+0000) Subject: [Bug 1781] longlong undefined in sntp handle_pkt() on Debian amd64. X-Git-Tag: NTP_4_2_7P115~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cf520d4341048ee5d8a5327471065c88939b2d1;p=thirdparty%2Fntp.git [Bug 1781] longlong undefined in sntp handle_pkt() on Debian amd64. Bump deps-ver and sntp/deps-ver to force each directory to be cleaned once, to work around build breaks triggered by changing erealloc() and estrdup() from functions to macros. bk: 4d28ca5fzkDKgNet3BaVEJfAY9a8Ag --- diff --git a/ChangeLog b/ChangeLog index 1a07c319b..6cd1ebfdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ * [Bug 1780] Windows ntpd 4.2.7p114 crashes in ioctl(). +* [Bug 1781] longlong undefined in sntp handle_pkt() on Debian amd64. (4.2.7p114) 2011/01/08 Released by Harlan Stenn * Fix for openssl pkg-config detection eval failure. * Add erealloc_zero(), refactor estrdup(), emalloc(), emalloc_zero() to diff --git a/deps-ver b/deps-ver index 9ad4b1451..83750ad1b 100644 --- a/deps-ver +++ b/deps-ver @@ -1 +1 @@ -Tue Nov 16 19:50:15 UTC 2010 +Sat Jan 8 18:11:35 UTC 2011 diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index 8163b72ee..fb7881806 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -2405,7 +2405,7 @@ ctl_putpeer( case CP_VARLIST: s = buf; be = buf + sizeof(buf); - if (s + strlen(peer_var[id].text) + 4 > be) + if (strlen(peer_var[id].text) + 4 > sizeof(buf)) break; /* really long var name */ snprintf(s, sizeof(buf), "%s=\"", peer_var[id].text); diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c index c6af615d5..9d37ffdb1 100644 --- a/ntpq/ntpq.c +++ b/ntpq/ntpq.c @@ -2716,12 +2716,10 @@ nextvar( ) { const char *cp; - char *np; + const char *np; const char *cpend; size_t srclen; size_t len; - char *npend; /* character after last */ - int quoted = 0; static char name[MAXVARLEN]; static char value[MAXVALLEN]; @@ -2741,6 +2739,7 @@ nextvar( * over any white space and terminate it. */ srclen = strcspn(cp, ",=\r\n"); + srclen = max(srclen, (size_t)(cpend - cp)); len = srclen; while (len > 0 && isspace(cp[len - 1])) len--; @@ -2766,35 +2765,37 @@ nextvar( * So far, so good. Copy out the value */ cp++; /* past '=' */ - while (cp < cpend && (isspace((int)*cp) && *cp != '\r' && *cp != '\n')) + while (cp < cpend && (isspace(*cp) && *cp != '\r' && *cp != '\n')) cp++; - np = value; - npend = &value[MAXVALLEN]; - while (cp < cpend && np < npend && ((*cp != ',') || quoted)) - { - quoted ^= ((*np++ = *cp++) == '"'); + np = cp; + if ('"' == *np) { + do { + np++; + } while (np < cpend && '"' != *np); + if (np < cpend) + np++; + } else { + while (np < cpend && ',' != *np) + np++; } - - /* - * Check if we overran the value buffer while still in a quoted string - * or without finding a comma - */ - if (np == npend && (quoted || *cp != ',')) + len = np - cp; + if (np >= cpend || ',' != *np || len >= sizeof(value)) return 0; + memcpy(value, cp, len); /* * Trim off any trailing whitespace */ - while (np > value && isspace((int)(*(np-1)))) - np--; - *np = '\0'; + while (len > 0 && isspace(value[len - 1])) + len--; + value[len] = '\0'; /* * Return this. All done. */ - if (cp != cpend) - cp++; - *datap = cp; - *datalen = cpend - cp; + if (np < cpend) + np++; + *datap = np; + *datalen = cpend - np; *vvalue = value; return 1; } diff --git a/sntp/Makefile.am b/sntp/Makefile.am index 82a6d93fd..84af7397f 100644 --- a/sntp/Makefile.am +++ b/sntp/Makefile.am @@ -188,7 +188,7 @@ $(srcdir)/sntp-opts.texi: $(srcdir)/sntp-opts.def $(srcdir)/version.def $(srcdir $(srcdir)/sntp.html: $(srcdir)/sntp-opts.menu $(srcdir)/sntp-opts.texi $(srcdir)/sntp.texi $(srcdir)/version.texi cd $(srcdir) && ( makeinfo --force --html --no-split -o sntp.html sntp.texi || true ) -../libntp/libntp.a: +../libntp/libntp.a: FRC cd ../libntp && $(MAKE) libntp.a libtool: $(LIBTOOL_DEPS) diff --git a/sntp/deps-ver b/sntp/deps-ver index dd28e403a..83750ad1b 100644 --- a/sntp/deps-ver +++ b/sntp/deps-ver @@ -1 +1 @@ -Fri Nov 13 17:21:31 UTC 2009 +Sat Jan 8 18:11:35 UTC 2011 diff --git a/sntp/main.c b/sntp/main.c index 7292d3773..806428ba2 100644 --- a/sntp/main.c +++ b/sntp/main.c @@ -205,7 +205,7 @@ handle_pkt ( char *p_SNTP_PRETEND_TIME; time_t pretend_time; #if SIZEOF_TIME_T == 8 - longlong ll; + long long ll; #else long l; #endif diff --git a/tests/libntp/Makefile.am b/tests/libntp/Makefile.am index c82d41fae..7f8ec4415 100644 --- a/tests/libntp/Makefile.am +++ b/tests/libntp/Makefile.am @@ -1,5 +1,5 @@ check_PROGRAMS = tests -LDADD = @LCRYPTO@ @GTEST_LDFLAGS@ @GTEST_LIBS@ @top_builddir@/libntp/libntp.a +LDADD = @top_builddir@/libntp/libntp.a @LCRYPTO@ @GTEST_LDFLAGS@ @GTEST_LIBS@ AM_CXXFLAGS = @GTEST_CXXFLAGS@ AM_CPPFLAGS = @GTEST_CPPFLAGS@ tests_SOURCES = $(top_srcdir)/sntp/tests_main.cpp \