]> git.ipfire.org Git - thirdparty/git.git/commitdiff
banned.h: mark non-reentrant gmtime, etc as banned
authorJeff King <peff@peff.net>
Tue, 1 Dec 2020 21:11:37 +0000 (13:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Dec 2020 22:37:27 +0000 (14:37 -0800)
The traditional gmtime(), localtime(), ctime(), and asctime() functions
return pointers to shared storage. This means they're not thread-safe,
and they also run the risk of somebody holding onto the result across
multiple calls (where each call invalidates the previous result).

All callers should be using their reentrant counterparts.

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 60a18d44033b207025294a3084cbf7c7c6f20876..ed11300bb2e4950b8a60d189b8ae2876535f0ea7 100644 (file)
--- a/banned.h
+++ b/banned.h
 #define vsprintf(buf,fmt,arg) BANNED(vsprintf)
 #endif
 
+#undef gmtime
+#define gmtime(t) BANNED(gmtime)
+#undef localtime
+#define localtime(t) BANNED(localtime)
+#undef ctime
+#define ctime(t) BANNED(ctime)
+#undef asctime
+#define asctime(t) BANNED(asctime)
+
 #endif /* BANNED_H */