summaryrefslogtreecommitdiff
path: root/libexec/getty
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2024-04-28 16:42:54 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2024-04-28 16:42:54 +0000
commitcdc51f7b7a4cf42e605daf34492d4fc5f193d7ed (patch)
tree975c084c53612016a8f0f9a65dc9f3347588fd77 /libexec/getty
parent891358d20de03c388fb10d0148c4660261604dda (diff)
gmtime(3) / locatime(3) can fail when timestamps are way off.
Add missing error checks to all calls under libexec/ Input & OK millert
Diffstat (limited to 'libexec/getty')
-rw-r--r--libexec/getty/main.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
index 3ac0939d8c8..dac5ad3449b 100644
--- a/libexec/getty/main.c
+++ b/libexec/getty/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.54 2019/06/28 13:32:53 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.55 2024/04/28 16:42:53 florian Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -562,10 +562,12 @@ putf(char *cp)
break;
case 'd': {
- (void)time(&t);
- (void)strftime(db, sizeof(db),
- "%l:%M%p on %A, %d %B %Y", localtime(&t));
- xputs(db);
+ struct tm *tm;
+ time(&t);
+ if ((tm = localtime(&t)) != NULL)
+ if (strftime(db, sizeof(db),
+ "%l:%M%p on %A, %d %B %Y", tm) != 0)
+ xputs(db);
break;
}