You are expected to be using e.g. %.254s
or in your case %.221s/%.32s
explicitly to specify that you are only going to process the first 254 characters of the parameter in any case.
That warning is supposed to ensure that you don't end up with an unexpectedly truncated string on the output side, but rather truncate the input in a meaningful way.
Alternatively, you should check the return value of snprintf
. If negative, then the output was truncated.
GCC9 will warn you when you did neither truncate the input (guaranteeing that no output truncation could have occurred), nor performed error handling in case the output got truncated.
In your specific case, it looks as if you are constructing a path (which is useless when truncated in any form), so validating the return value of snprintf
is what you actually should do.