Skip to content

Commit 1fbfdf5

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 72ffeb9 commit 1fbfdf5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

banned.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,13 @@
2929
#define vsprintf(buf,fmt,arg) BANNED(vsprintf)
3030
#endif
3131

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+
3241
#endif /* BANNED_H */

0 commit comments

Comments
 (0)