Message ID | 20201201211138.33850-2-gitster@pobox.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 91aef030152d121f6b4bc3b933c696073ba073e2 |
Headers | show |
Series | [v2,1/2] banned.h: mark non-reentrant gmtime, etc as banned | expand |
On Tue, Dec 1, 2020 at 4:12 PM Junio C Hamano <gitster@pobox.com> wrote: > 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 stftime() > as well as its more conveinent strbuf_addftime() wrapper, let's ban both > of those. This still needs a s/conveinent/convenient/ mentioned earlier[1]. [1]: https://lore.kernel.org/git/CAPig+cT=gMEuKkbJefT9yxWWB5VC1fj6T+ofjn_saEEeEeU_MA@mail.gmail.com/
Eric Sunshine <sunshine@sunshineco.com> writes: > On Tue, Dec 1, 2020 at 4:12 PM Junio C Hamano <gitster@pobox.com> wrote: >> 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 stftime() >> as well as its more conveinent strbuf_addftime() wrapper, let's ban both >> of those. > > This still needs a s/conveinent/convenient/ mentioned earlier[1]. AH, thanks, fixed.
On Tue, Dec 01, 2020 at 02:07:55PM -0800, Junio C Hamano wrote: > > This still needs a s/conveinent/convenient/ mentioned earlier[1]. > > AH, thanks, fixed. That was my only nit, but I'm certainly quite happy to see these get picked up. Here's my: Reviewed-by: Taylor Blau <me@ttaylorr.com> if you need it (which I doubt, but there it is anyway). Thanks, Taylor
diff --git a/banned.h b/banned.h index ed11300bb2..7ab4f2e492 100644 --- a/banned.h +++ b/banned.h @@ -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 */