3 ms·
The issue is that strncpy doesn't guarantee that the destination string is null-terminated after a copy, particularly in the case where n is shorter than the or
by opticfluorine 7y ago
The issue is that strncpy doesn't guarantee that the destination string is null-terminated after a copy, particularly in the case where n is shorter than the original string, so you could run into overflows if you then ran strlen() or similar against it.
Here's a good explanation from Raymond Chen: https://devblogs.microsoft.com/oldnewthing/?p=36773 https://devblogs.microsoft.com/oldnewthing/?p=36773