summaryrefslogtreecommitdiff
path: root/bin/ps
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2024-04-28 16:43:16 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2024-04-28 16:43:16 +0000
commit09dd1ad3e6ca879f5fd074c8e48b533da6752986 (patch)
treec8c528ced7025c5a9b7201d35ca55ff6986fb647 /bin/ps
parentcdc51f7b7a4cf42e605daf34492d4fc5f193d7ed (diff)
gmtime(3) / locatime(3) can fail when timestamps are way off.
Add missing error checks to all calls under bin/ Input & OK millert
Diffstat (limited to 'bin/ps')
-rw-r--r--bin/ps/print.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 7c7f75d74b8..5d432f5795f 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.88 2024/01/28 19:05:33 deraadt Exp $ */
+/* $OpenBSD: print.c,v 1.89 2024/04/28 16:43:15 florian Exp $ */
/* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */
/*-
@@ -524,6 +524,10 @@ started(const struct pinfo *pi, VARENT *ve)
startt = kp->p_ustart_sec;
tp = localtime(&startt);
+ if (tp == NULL) {
+ (void)printf("%-*s", v->width, "-");
+ return;
+ }
if (!now)
(void)time(&now);
if (now - kp->p_ustart_sec < 12 * SECSPERHOUR) {