https://github.com/git/git/blob/master/strbuf.h
https://github.com/git/git/blob/master/strbuf.c
See this for the story of why strncpy/strncat are insecure:
https://en.wikipedia.org/wiki/C_string_handling#Replacements
11–20 of 329 posts
https://github.com/git/git/blob/master/strbuf.h
https://github.com/git/git/blob/master/strbuf.c
See this for the story of why strncpy/strncat are insecure:
https://en.wikipedia.org/wiki/C_string_handling#Replacements
Earlier quoted context omitted.
Yes, and interestingly, because even when used correctly they "complicate audits". This is an interesting use of preprocessor macros, I'm strongly debating introducing something like this at work.
I'm not an expert in C, but then what's the issue with strncpy() or any "n" functions? It prevents overflow AFAIK. Also what is the alternative (memcpy?) and why?
(See also https://linux.die.net/man/3/strncpy )
Also found https://github.com/mubix/netview/blob/master/banned.h on Github with a better list.
I guess they care too much about portability to use "pragma GCC poison"?
Wanting code to compile on something other than gcc is not "caring too much", it's being responsible
Earlier quoted context omitted.
Yes, and interestingly, because even when used correctly they "complicate audits". This is an interesting use of preprocessor macros, I'm strongly debating introducing something like this at work.
I'm not an expert in C, but then what's the issue with strncpy() or any "n" functions? It prevents overflow AFAIK. Also what is the alternative (memcpy?) and why?
Here's a good explanation from Raymond Chen: https://devblogs.microsoft.com/oldnewthing/?p=36773
Earlier quoted context omitted.
Yes, and interestingly, because even when used correctly they "complicate audits". This is an interesting use of preprocessor macros, I'm strongly debating introducing something like this at work.
I'm not an expert in C, but then what's the issue with strncpy() or any "n" functions? It prevents overflow AFAIK. Also what is the alternative (memcpy?) and why?
Earlier quoted context omitted.
Yes, and interestingly, because even when used correctly they "complicate audits". This is an interesting use of preprocessor macros, I'm strongly debating introducing something like this at work.
I'm not an expert in C, but then what's the issue with strncpy() or any "n" functions? It prevents overflow AFAIK. Also what is the alternative (memcpy?) and why?
> Copies the first num characters of source to destination. If the end of the source C string (which is signaled by a null-character) is found before num characters have been copied, destination is padded with zeros until a total of num characters have been written to it.
No null-character is implicitly appended at the end of destination if source is longer than num. Thus, in this case, destination shall not be considered a null terminated C string (reading it as such would overflow).
Earlier quoted context omitted.
Wanting code to compile on something other than gcc is not "caring too much", it's being responsible
Responsible? What an hyperbolic statement. Could you enlighten me on what would be the significant negative consequences? I hope that your mental equation take into account the missed usefulness of GCC only attributes, flags and extensions by being clang compatible.
And that's not saying that GCC extensions are not useful, but they should not be considered the norm
Earlier quoted context omitted.
Yes, and interestingly, because even when used correctly they "complicate audits". This is an interesting use of preprocessor macros, I'm strongly debating introducing something like this at work.
I'm not an expert in C, but then what's the issue with strncpy() or any "n" functions? It prevents overflow AFAIK. Also what is the alternative (memcpy?) and why?
Earlier quoted context omitted.
Responsible? What an hyperbolic statement. Could you enlighten me on what would be the significant negative consequences? I hope that your mental equation take into account the missed usefulness of GCC only attributes, flags and extensions by being clang compatible.
I don't know what to tell you. Do you think all compilers should implement all GCC proprietary extensions, basically creating a parallel C standard? And that's not saying that GCC extensions are not useful, but they should not be considered the norm