]> git.ipfire.org Git - thirdparty/git.git/commitdiff
banned.h: mark ctime_r() and asctime_r() as banned
authorJeff King <peff@peff.net>
Tue, 1 Dec 2020 21:11:38 +0000 (13:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Dec 2020 22:30:39 +0000 (14:30 -0800)
The ctime_r() and asctime_r() functions are reentrant, but have
no check that the buffer we pass in is long enough (the manpage says it
"should have room for at least 26 bytes"). Since this is such an
easy-to-get-wrong interface, and since we have the much safer strftime()
as well as its more convenient strbuf_addftime() wrapper, let's ban both
of those.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
banned.h

index ed11300bb2e4950b8a60d189b8ae2876535f0ea7..7ab4f2e49219bdb38e4fe4e5b85d5a0cc3765566 100644 (file)
--- a/banned.h
+++ b/banned.h
 #define localtime(t) BANNED(localtime)
 #undef ctime
 #define ctime(t) BANNED(ctime)
+#undef ctime_r
+#define ctime_r(t, buf) BANNED(ctime_r)
 #undef asctime
 #define asctime(t) BANNED(asctime)
+#undef asctime_r
+#define asctime_r(t, buf) BANNED(asctime_r)
 
 #endif /* BANNED_H */