summaryrefslogtreecommitdiff
path: root/usr.bin/kdump
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2014-12-16 03:19:24 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2014-12-16 03:19:24 +0000
commit80e3fae0bde469cf50a4aee8d4a759884c30e3e5 (patch)
tree192385d3ceaabd5738fbb59fd633954598264173 /usr.bin/kdump
parentbd96a67df3fe788dd3ed548363a21f09adaa82e1 (diff)
Don't display formatted time if localtime() fails.
Avoids a crash in strftime() found with the afl fuzzer. ok guenther@
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r--usr.bin/kdump/ktrstruct.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/kdump/ktrstruct.c b/usr.bin/kdump/ktrstruct.c
index 03910666477..b218ee2027e 100644
--- a/usr.bin/kdump/ktrstruct.c
+++ b/usr.bin/kdump/ktrstruct.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ktrstruct.c,v 1.8 2014/12/15 01:48:54 guenther Exp $ */
+/* $OpenBSD: ktrstruct.c,v 1.9 2014/12/16 03:19:23 jsg Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -146,8 +146,11 @@ print_time(time_t t, int relative, int have_subsec)
if (!relative) {
tm = localtime(&t);
- (void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
- printf("<\"%s\">", timestr);
+ if (tm != NULL) {
+ (void)strftime(timestr, sizeof(timestr), TIME_FORMAT,
+ tm);
+ printf("<\"%s\">", timestr);
+ }
}
}