]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
check return value of strftime()
authorMark Andrews <marka@isc.org>
Thu, 6 Sep 2001 00:34:06 +0000 (00:34 +0000)
committerMark Andrews <marka@isc.org>
Thu, 6 Sep 2001 00:34:06 +0000 (00:34 +0000)
lib/isc/unix/time.c

index 13ad886cd1fd3f0fc04d5d964fc113385a29ca25..8a5f1a1008e0670eb646094f66ca85b9add1c03f 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: time.c,v 1.34.2.3 2001/09/05 17:04:43 gson Exp $ */
+/* $Id: time.c,v 1.34.2.4 2001/09/06 00:34:06 marka Exp $ */
 
 #include <config.h>
 
@@ -394,8 +394,11 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
        REQUIRE(len > 0);
 
        now = (time_t) t->seconds;
-       strftime(buf, len, "%b %d %X", localtime(&now));
-       flen = strlen(buf);
-       snprintf(buf + flen, len - flen,
-                ".%03u", t->nanoseconds / 1000000);
+       flen = strftime(buf, len, "%b %d %X", localtime(&now));
+       INSIST(flen < len);
+       if (flen != 0)
+               snprintf(buf + flen, len - flen,
+                        ".%03u", t->nanoseconds / 1000000);
+       else
+                snprintf(buf, len, "Bad 00 99:99:99.999");
 }