Closed havardAasen closed 11 months ago
How many does this catch? I have notice that the compile log is sprinkled with hundreds of string truncation warnings.
On 13.12.2023 17:13, andypugh wrote:
How many does this catch? I have notice that the compile log is sprinkled with hundreds of string truncation warnings.
Only three, it was all from that file. If you are satisfied with how i solved it, I can see if I can't fix some more of them, but not hundreds.
I forgot to check if they are present in 2.9, should i target any specific branch?
There are many truncation warnings when compiling 2.9. So I would suggest targetting that. I probably won't merge them until after 2.9.2 though.
This fixes quite a lot of the warning for string truncation. The one responsible for most of them was fixed with 7f54de8.
I changed my mind, there was quite a backlog of 2.9 fixes which I am working through. This might as well go in too.
We check the length of the string before using
strncpy()
, we check with>=
which means that the string must be one smaller and therefore have room for at least one NULL terminating character.The previous solution also checked for NULL terminated strings but the compiler wasn't satisfied with it happening after the command to
strncpy()
.For the error message, the unnecessary cast to unsigned long is removed, and the format string has been changed to
zu
.