On Tue, May 1, 2018 at 10:54 AM, Derek Martin <inva...@pizzashack.org> wrote: > 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.
In the case of this specific patch, I think it's safe to ignore, and let it silently truncate. Per RFC 4288 (superseded by RFC 6838), the type and subtype are restricted to 127 characters maximum, and should be 64 characters or less. So STRING is long enough to hold the maximums, including the "/" and terminating NULL, and won't truncate any legal values. Cheers, Ammon