Re:Massacring C Pointers
by _kst_ on Tuesday June 26, 2018 @06:15PM
(#17404395)
I've mentioned elsewhere that strncpy is not a "safer" strcpy.
Even if it were, there's safety and there's safety. A function (like strncat, for example) that quietly truncates your data if it's too long isn't necessarily better than one that quietly ignores array overruns. Consider what happens if
"rm -rf $HOME/tmpdir"
is quietly truncated to
"rm -rf $HOME/"
Even if it were, there's safety and there's safety. A function (like strncat, for example) that quietly truncates your data if it's too long isn't necessarily better than one that quietly ignores array overruns. Consider what happens if "rm -rf $HOME/tmpdir" is quietly truncated to "rm -rf $HOME/"