AW: [PATCH] svlogd: Fix potential deref-of-null
Walter Harms
wharms at bfs.de
Mon Oct 28 10:39:17 UTC 2024
mmh, for my curiosity
this is a replacement for ctime() ?
why not using strftime() ( and time() ) ?
and what is the possible failure condition for gmtime_r() ? (did not dive into glibc sources today)
thx
wh
________________________________________
Von: busybox <busybox-bounces at busybox.net> im Auftrag von Maks Mishin <maks.mishinfz at gmail.com>
Gesendet: Dienstag, 17. September 2024 06:37
An: busybox at busybox.net
Betreff: [PATCH] svlogd: Fix potential deref-of-null
Pointer, returned from function 'gmtime_r' at svlogd.c:355, may be NULL
and is dereferenced at svlogd.c:358.
Found by RASU JSC with SVACE.
Signed-off-by: Maks Mishin <maks.mishinFZ at gmail.com>
---
runit/svlogd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/runit/svlogd.c b/runit/svlogd.c
index f7576f0fa..ff7224a34 100644
--- a/runit/svlogd.c
+++ b/runit/svlogd.c
@@ -353,6 +353,9 @@ static void fmt_time_human_30nul(char *s, char dt_delim)
xgettimeofday(&tv);
ptm = gmtime_r(&tv.tv_sec, &tm);
+ if (ptm == NULL)
+ return;
+
/* ^^^ using gmtime_r() instead of gmtime() to not use static data */
sprintf(s, "%04u-%02u-%02u%c%02u:%02u:%02u.%06u000",
(unsigned)(1900 + ptm->tm_year),
--
2.34.1
_______________________________________________
busybox mailing list
busybox at busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list