News for hackers. Stuff that matters.
Re:Banned C standard library functions in Git source code by asveikau on Sunday August 25, 2019 @10:59AM (#20793344)
A C programmer reading this list knows exactly why they are there. It is not at all a controversial list.

Edit: I guess some down voter doesn't believe me but it continues to be true. They are all string functions. Most of them do not take an output buffer size, so a source string exceeding the destination buffer will overflow. Others, like strncpy, take an output buffer size but will not null terminate when exceeded, so the buffer size must be reduced by 1 by the caller and potentially manually terminates, which is too easy to not consider. But any C programmer with significant experience already knows these pitfalls. So it's not controversial.

Re:Banned C standard library functions in Git source code by magnetic on Sunday August 25, 2019 @11:52AM (#20793594)
You explained it in 2 lines that would make for great comments.

It seems useful to educate C programmers who don't have "significant experience" because, well, by definition, not every C programmer has "significant experience" and they are the ones who would benefit most from learning this.

It's not about being controversial: nobody's going to disagree with your explanation (it is what it is - it's not an opinion).

Re:Banned C standard library functions in Git source code by asveikau on Sunday August 25, 2019 @12:41PM (#20793904)
I don't remember how I learned this. But it happens pretty naturally working with C a lot and doing things like reading documentation and code. To be clear this is not elitism or something of the sort, I am not at all pessimistic that new people won't learn it. It just needs to happen in its due time.

So I would say... What good is a verbose comment to explain? Somebody who doesn't instantly understand why it's banned can read the big warnings on the manpage, or they can google it and land on good explanations on sites like Stack Overflow, or they can look at the function signatures and come up with a correct guess. Then boom. They know. And from there they can assess other interfaces and see if they suffer the same weakness.

This ability tends to come from simple exposure.

Re:Banned C standard library functions in Git source code by bhk on Sunday August 25, 2019 @11:58AM (#20793645)
If every C programmer knew, then there would be no need to ban them
Re:Banned C standard library functions in Git source code by Dylan16807 on Sunday August 25, 2019 @03:14PM (#20794883)
That's not true. People don't staunchly avoid situations that have pointless sharp edges. Putting up caution tape, despite everyone being aware of the danger, is very often a useful activity.
Re:Banned C standard library functions in Git source code by asveikau on Sunday August 25, 2019 @12:36PM (#20793880)
I actually wonder why they do it.

Linkers already warn for this stuff. Doing it this way requires every source file to include banned.h, which I would guess is done by including it from some other common header, but that's not fool proof either.

[dead]
Re:Banned C standard library functions in Git source code by bhk on Sunday August 25, 2019 @01:37PM (#20794277)
Re:Banned C standard library functions in Git source code by ncmncm on Wednesday August 28, 2019 @12:34AM (#20816810)
Does not apply. Nobody is born with C skills.

Competence can be measured objectively. Failure to understand array bounds is prima facie evidence of lack.

Re:Banned C standard library functions in Git source code by ikeyany on Sunday August 25, 2019 @12:07PM (#20793691)
FYI that response insinuates that noname120 is not a C programmer...
[dead]
Re:Banned C standard library functions in Git source code by Merg on Monday August 26, 2019 @04:57AM (#20798314)
Just open the docs. Seriously, first link in Google/DDG/Bing on topic of "<any c string routine> safety" will explain it to you. I am self-taught and I can see it.

Seriously, just looking at function arguments shows you, there is a problem under the hood. Reading docs also will point out.

It is open-source, read and learn from Git, Linux code and so on. If you do not have experience is sysdev or high security, just don't contribute there.

This is like saying, construction engineering is gatekeeping beginners, because you have to work for few years before you can start your own project.

Re:Banned C standard library functions in Git source code by mhh__ on Sunday August 25, 2019 @05:34PM (#20795743)
I think you can. The whole point of being open source and using a project like cough git (since we're here), is that if you don't like it you can fork it. If you don't allow forks then I agree you aren't open source
Re:Banned C standard library functions in Git source code by philwelch on Sunday August 25, 2019 @06:07PM (#20795916)
Looks like they did.
Re:Banned C standard library functions in Git source code by noname120 on Sunday August 25, 2019 @11:38AM (#20793531)
That's gatekeeping. If a junior developer starts working on this project they might bother a more senior developer who has better things to do with their time, or inline the definition of one of the functions out of frustration.
Re:Banned C standard library functions in Git source code by philwelch on Sunday August 25, 2019 @06:04PM (#20795899)
Git, like the Linux kernel, is essential, basic infrastructure that everybody uses and that needs to remain reliable. It's not a volunteer training project for dilettantes and neophytes. Gatekeeping is a deliberate part of how these projects are run and the results speak for themselves.
Re:Banned C standard library functions in Git source code by noname120 on Sunday August 25, 2019 @06:11PM (#20795944)
Makes sense, thanks for taking the time to answer.
Re:Banned C standard library functions in Git source code by noname120 on Sunday August 25, 2019 @05:29PM (#20795725)
I'd be interested in knowing which part of the comment you don't agree with and why.