net: ipconfig: Replace strncpy with strscpy in ic_proto_name (details)
Commit
ff736a286116d462a4067ba258fa351bc0b4ed80
by kuba
net: ipconfig: Replace strncpy with strscpy in ic_proto_name
strncpy() is deprecated [1] for NUL-terminated destination buffers because it does not guarantee NUL termination. Replace it with strscpy() to ensure the destination buffer is always NUL-terminated and to avoid any additional NUL padding.
Although the identifier buffer has 252 usable bytes, strncpy() copied only up to 251 bytes to the zero-initialized buffer, relying on the last byte to act as an implicit NUL terminator. Switching to strscpy() avoids this implicit behavior and does not use magic numbers.
The source string is also NUL-terminated and satisfies the __must_be_cstr() requirement of strscpy().