News for hackers. Stuff that matters.
Re:About the security content of macOS Monterey 12.2 by jjtheblunt on Wednesday January 26, 2022 @10:38PM (#30095893)
or use safe libraries, strncpy rather than strcpy, and so on?
Re:About the security content of macOS Monterey 12.2 by saagarjha on Wednesday January 26, 2022 @10:50PM (#30095970)
strncpy is not a really meant to be a “safe” function.
Re:About the security content of macOS Monterey 12.2 by tialaramex on Thursday January 27, 2022 @04:05AM (#30098039)
In a sense strncpy() is exactly the sort of unsafe nonsense that got C into trouble.

C's strings are zero byte terminated, but the strings strncpy() is intended to target are not, they're file names in a fixed length buffer. So, it's fine to fill the entire buffer with text and no terminator, or to write a single byte of text, and fill the rest with zero bytes. If that's the exact problem you have, strncpy() is the exact feature you wanted. Otherwise it isn't.

If you aren't aware of why Unix wanted this feature it's a very strange thing to find in C's small standard library.