banned.h: mark non-reentrant gmtime, etc as banned
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>
Jeff King committed
Dec 1, 2020 at 13:11 UTC
1fbfdf556f2abc708183caca53ae4e2881b46ae2
1 file changed
+9
banned.h
+9
@@ -29,4 +29,13 @@
29
#define vsprintf(buf,fmt,arg) BANNED(vsprintf)
30
#endif
31
32
+#undef gmtime
33
+#define gmtime(t) BANNED(gmtime)
34
+#undef localtime
35
+#define localtime(t) BANNED(localtime)
36
+#undef ctime
37
+#define ctime(t) BANNED(ctime)
38
+#undef asctime
39
+#define asctime(t) BANNED(asctime)
40
+
41
#endif /* BANNED_H */