3 ms·
The size of the buffer pointed to by s may be larger than the current string it holds. It may also be uninitialized.
by jjnoakes 7y ago
The size of the buffer pointed to by s may be larger than the current string it holds. It may also be uninitialized.
- saagarjha 7y agoOr point to the wrong thing, or point to unmapped memory, or be const, or…there's a lot of things that can go wrong with this function.
- jjnoakes 7y agoThe things I listed are things the function does right as written but could not do if it worked the way suggested above. The things you listed are general concerns in C which are unrelated to both the correct implementation and the suggested changes.
- dhsysusbsjsi 7y agoThat’s what strncpy() is for