Ex17 strncpy bug doesn't occur?


#1

I’m noticing that when I try to demonstrate the strncpy bug that it simply trunicates the string down to the max size. I didn’t see any sign of issues or unusual behavior. Is it possible this bug is fixed now?

bruda@cyborg ~/C (git)-[master] % gcc --version
gcc (GCC) 8.2.1 20180831
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bruda@cyborg ~/C (git)-[master] % ldd --version                                                                                                                                                                   :(
ldd (GNU libc) 2.28
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

#2

Nevermind. I see it now. Printing the string continues instead of stopping like its supposed to, resulting in a little ugly output.


#3

Yes, this is why C bugs are so deadly. 90% of the time it works fine. Then 9% of the time the bug gets hit, and even then those times it’ll just work weird. It’s 1% of the time that someone figures out how to exploit it and break in, but since it worked 99% of the time you can’t believe it.