* [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 <stenn@ntp.org>
* Fix for openssl pkg-config detection eval failure.
* Add erealloc_zero(), refactor estrdup(), emalloc(), emalloc_zero() to
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);
)
{
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];
* 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--;
* 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;
}
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 \