Skip to content

Commit

Permalink
banned.h: mark ctime_r() and asctime_r() as banned
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
peff authored and gitster committed Dec 2, 2020
1 parent 1fbfdf5 commit 91aef03
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions banned.h
Expand Up @@ -35,7 +35,11 @@
#define localtime(t) BANNED(localtime)
#undef ctime
#define ctime(t) BANNED(ctime)
#undef ctime_r
#define ctime_r(t, buf) BANNED(ctime_r)
#undef asctime
#define asctime(t) BANNED(asctime)
#undef asctime_r
#define asctime_r(t, buf) BANNED(asctime_r)

#endif /* BANNED_H */

0 comments on commit 91aef03

Please sign in to comment.