Skip to content

Commit 91aef03

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

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

banned.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
#define localtime(t) BANNED(localtime)
3636
#undef ctime
3737
#define ctime(t) BANNED(ctime)
38+
#undef ctime_r
39+
#define ctime_r(t, buf) BANNED(ctime_r)
3840
#undef asctime
3941
#define asctime(t) BANNED(asctime)
42+
#undef asctime_r
43+
#define asctime_r(t, buf) BANNED(asctime_r)
4044

4145
#endif /* BANNED_H */

0 commit comments

Comments
 (0)