]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4852. [bug] Handle strftime() failing in isc_time_formatISO8601ms.
authorMark Andrews <marka@isc.org>
Mon, 1 Jan 2018 23:48:08 +0000 (10:48 +1100)
committerMark Andrews <marka@isc.org>
Mon, 1 Jan 2018 23:48:08 +0000 (10:48 +1100)
                        Add REQUIRE's and INSIST's to isc_time_formattimestamp,
                        isc_time_formathttptimestamp, isc_time_formatISO8601,
                        isc_time_formatISO8601ms. [RT #46892]

CHANGES
lib/isc/unix/time.c
lib/isc/win32/time.c

diff --git a/CHANGES b/CHANGES
index 538bcfe41da33f2e512272dd15fcce3af63b3614..b0dce52271fb3860da9e80e8317141e6114df902 100644 (file)
--- 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]
 
index 71bf8504cada0641c82bde91f9528a319be0c51e..5703ba7606635988c8b8162abe6a6a4e0ea0a6a4 100644 (file)
@@ -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;
index 7f21e287b515f12ccfddac469dc3d8ead7554c25..a6234c697083dca9dbc2dbc98cebbbe6270870a9 100644 (file)
@@ -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);