3 ms·
The Git Mailing List Archive on lore.kernel.org (found in the README from the git mirror on GitHub) has more context [0] [1] [2]. From Jeff King on 2018-07-24:
by abetusk 6y ago
The Git Mailing List Archive on lore.kernel.org (found in the README from the git mirror on GitHub) has more context [0] [1] [2]. From Jeff King on 2018-07-24:
The strncpy() function is less horrible than strcpy(), but
is still pretty easy to misuse because of its funny
termination semantics. Namely, that if it truncates it omits
the NUL terminator, and you must remember to add it
yourself. Even if you use it correctly, it's sometimes hard
for a reader to verify this without hunting through the
code. If you're thinking about using it, consider instead:
- strlcpy() if you really just need a truncated but
NUL-terminated string (we provide a compat version, so
it's always available)
- xsnprintf() if you're sure that what you're copying
should fit
- strbuf or xstrfmt() if you need to handle
arbitrary-length heap-allocated strings
I just did a search on the keywords 'banned' and 'strncpy' [2]
[0] https://lore.kernel.org/git/20180724092828.GD3288@sigill.intra.peff.net/ https://lore.kernel.org/git/20180724092828.GD3288@sigill.int...
[1] https://lore.kernel.org/git/20190103044941.GA20047@sigill.intra.peff.net/ https://lore.kernel.org/git/20190103044941.GA20047@sigill.in...
[2] https://lore.kernel.org/git/20190102093846.6664-1-e@80x24.org/ https://lore.kernel.org/git/20190102093846.6664-1-e@80x24.or...
[3] https://lore.kernel.org/git/?q=banned+strncpy https://lore.kernel.org/git/?q=banned+strncpy
- js2 6y agoPsst: https://github.com/git/git/commits/master/banned.h https://github.com/git/git/commits/master/banned.h (Git development is done by emailing patches. Those patches include the git commit message, which we can see just by looking at the history of the file. Sometimes there's additional discussion on the ML, but the most important details are in the commit message because the git development team is very disciplined about that.)
- abetusk 6y agoHa, yep, whoops