On Tue, May 01, 2018 at 11:59:27AM -0500, Derek Martin wrote: > FWIW, I've said this before, but I think anywhere strncpy() is used, > code that does the above should replace it. This avoids silent > truncation (which strncpy() does), and checking the return is required > to make sure snprintf() actually did something, and you're not > operating on uninitialized memory (or whatever).
Sorry, this was badly worded. Checking the return value is required to ensure that snprintf() wrote all the data (rc < size, NOT <= size), assuming you want that. If you actually want it to silently truncate, which you may if for example you're formatting the index, then you can ignore it. That may or may not cause an error if compiled with -Wall -Werror flags... the glibc folks have been doing a lot of that lately. -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience.
pgpl1gP1zGlpS.pgp
Description: PGP signature
