banned.h: mark ctime_r() and asctime_r() as banned

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>

Jeff King committed Dec 1, 2020 at 13:11 UTC 91aef030152d121f6b4bc3b933c696073ba073e2
1 file changed +4
banned.h
+4
@@ -35,7 +35,11 @@
35 #define localtime(t) BANNED(localtime)
36 #undef ctime
37 #define ctime(t) BANNED(ctime)
38 +#undef ctime_r
39 +#define ctime_r(t, buf) BANNED(ctime_r)
40 #undef asctime
41 #define asctime(t) BANNED(asctime)
42 +#undef asctime_r
43 +#define asctime_r(t, buf) BANNED(asctime_r)
44
45 #endif /* BANNED_H */