From: Mark Andrews Date: Mon, 1 Jan 2018 23:48:08 +0000 (+1100) Subject: 4852. [bug] Handle strftime() failing in isc_time_formatISO8601ms. X-Git-Tag: v9.13.0~313 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=7770e0b069cb91b5c77245830e86937e1e2116a8;p=thirdparty%2Fbind9.git 4852. [bug] Handle strftime() failing in isc_time_formatISO8601ms. Add REQUIRE's and INSIST's to isc_time_formattimestamp, isc_time_formathttptimestamp, isc_time_formatISO8601, isc_time_formatISO8601ms. [RT #46892] --- diff --git a/CHANGES b/CHANGES index 538bcfe41da..b0dce52271f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +4852. [bug] Handle strftime() failing in isc_time_formatISO8601ms. + Add REQUIRE's and INSIST's to isc_time_formattimestamp, + isc_time_formathttptimestamp, isc_time_formatISO8601, + isc_time_formatISO8601ms. [RT #46892] + 4851. [port] Support using kyua as well as atf-run to run the unit tests. [RT #46853] diff --git a/lib/isc/unix/time.c b/lib/isc/unix/time.c index 71bf8504cad..5703ba76066 100644 --- a/lib/isc/unix/time.c +++ b/lib/isc/unix/time.c @@ -381,6 +381,9 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) { struct tm tm; #endif + REQUIRE(t != NULL); + INSIST(t->nanoseconds < NS_PER_S); + REQUIRE(buf != NULL); REQUIRE(len > 0); now = (time_t) t->seconds; @@ -406,6 +409,9 @@ isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len) { struct tm tm; #endif + REQUIRE(t != NULL); + INSIST(t->nanoseconds < NS_PER_S); + REQUIRE(buf != NULL); REQUIRE(len > 0); /* @@ -429,6 +435,7 @@ isc_time_parsehttptimestamp(char *buf, isc_time_t *t) { REQUIRE(buf != NULL); REQUIRE(t != NULL); + p = isc_tm_strptime(buf, "%a, %d %b %Y %H:%M:%S", &t_tm); if (p == NULL) return (ISC_R_UNEXPECTED); @@ -489,6 +496,9 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) { struct tm tm; #endif + REQUIRE(t != NULL); + INSIST(t->nanoseconds < NS_PER_S); + REQUIRE(buf != NULL); REQUIRE(len > 0); now = (time_t)t->seconds; @@ -508,6 +518,9 @@ isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len) { struct tm tm; #endif + REQUIRE(t != NULL); + INSIST(t->nanoseconds < NS_PER_S); + REQUIRE(buf != NULL); REQUIRE(len > 0); now = (time_t)t->seconds; diff --git a/lib/isc/win32/time.c b/lib/isc/win32/time.c index 7f21e287b51..a6234c69708 100644 --- a/lib/isc/win32/time.c +++ b/lib/isc/win32/time.c @@ -272,7 +272,10 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) { char DateBuf[50]; char TimeBuf[50]; + REQUIRE(t != NULL); + REQUIRE(buf != NULL); REQUIRE(len > 0); + if (FileTimeToLocalFileTime(&t->absolute, &localft) && FileTimeToSystemTime(&localft, &st)) { GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, "dd-MMM-yyyy", @@ -296,7 +299,10 @@ isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len) { /* strftime() format: "%a, %d %b %Y %H:%M:%S GMT" */ + REQUIRE(t != NULL); + REQUIRE(buf != NULL); REQUIRE(len > 0); + if (FileTimeToSystemTime(&t->absolute, &st)) { GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, "ddd',' dd MMM yyyy", DateBuf, 50); @@ -318,6 +324,7 @@ isc_time_parsehttptimestamp(char *buf, isc_time_t *t) { REQUIRE(buf != NULL); REQUIRE(t != NULL); + p = isc_tm_strptime(buf, "%a, %d %b %Y %H:%M:%S", &t_tm); if (p == NULL) return (ISC_R_UNEXPECTED); @@ -379,7 +386,10 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) { /* strtime() format: "%Y-%m-%dT%H:%M:%SZ" */ + REQUIRE(t != NULL); + REQUIRE(buf != NULL); REQUIRE(len > 0); + if (FileTimeToSystemTime(&t->absolute, &st)) { GetDateFormat(LOCALE_NEUTRAL, 0, &st, "yyyy-MM-dd", DateBuf, 50); @@ -400,7 +410,10 @@ isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len) { /* strtime() format: "%Y-%m-%dT%H:%M:%S.SSSZ" */ + REQUIRE(t != NULL); + REQUIRE(buf != NULL); REQUIRE(len > 0); + if (FileTimeToSystemTime(&t->absolute, &st)) { GetDateFormat(LOCALE_NEUTRAL, 0, &st, "yyyy-MM-dd", DateBuf, 50);