musl libc (an alternative libc) provides implementations of these functions that are memory-safe. (It only works on Linux though.)
Banned C standard library functions in Git source code
61–70 of 329 posts
Re: Banned C standard library functions in Git source code
#62Earlier quoted context omitted.
Like essentially all C programs.
What's a good library for this kind of boilerplate? A lightweight one if possible, i.e. not fucking glib
Re: Banned C standard library functions in Git source code
#63K&R is turning in its grave.
Re: Banned C standard library functions in Git source code
#64For anybody else: Why is strncpy insecure? https://stackoverflow.com/questions/869883/why-is-strncpy-in... > strncpy() doesn't require NUL termination, and is therefore susceptible to a variety of exploits.
Re: Banned C standard library functions in Git source code
#65Why is there no brief explanations in this code why each function is banned?
Just to make it clear. I'm aware of the fact that these functions have security implications. Nonetheless when such decisions are made, I believe it's important to explain them—at least briefly—directly in the code itself.
They could rename them as “sorry X is unsafe and creates too much trouble” maybe, but in today’s internet “X considered harmful” is a common search query that everyone in the field is expected to know.
Re: Banned C standard library functions in Git source code
#66That's a surprisingly small list, missing e.g. sscanf / gets / strtok / all the other "usual suspects" at least
I don't see a huge problem with strtok as long as it isn't a multi threaded program. It is not in gets territory which is literally impossible to use correctly.
Re: Banned C standard library functions in Git source code
#67I'm glad to see that setjmp() and longjmp() are still allowed. I'm just kidding by the way. For those C programmers who haven't encountered these before, it is a powerful way to do a "goto" in C. Powerful in the sense that you can jump anywhere, not limited to the same function. If it's used at all these days, it's used for exception handling. More info: https://en.wikipedia.org/wiki/Setjmp.h
Re: Banned C standard library functions in Git source code
#68Re: Banned C standard library functions in Git source code
#69Re: Banned C standard library functions in Git source code
#70Earlier quoted context omitted.
Just to make it clear. I'm aware of the fact that these functions have security implications. Nonetheless when such decisions are made, I believe it's important to explain them—at least briefly—directly in the code itself.
With the way they are banned, you see it only as a compiler warning on implicit declaration of function (or at linking stage, if warnings are suppressed; idk what exact build process is). Afair, there is no evidence of banned.h in an error trace. So you have to look it up by yourself anyway. They could rename them as “sorry X is unsafe and creates too much trouble” maybe, but in today’s internet “X considered harmful…