utils: Belt and braces to satisfy gcc

GCC was upset that it was theoretically possible for this
format string to result in a buffer overrun.  This is because
it could not work out that `i` would never be negative. To
silence the warning, we use %u and cast to unsigned during the
formatting of the output filename.

Signed-off-by: Daniel Silverstone <dsilvers@netsurf-browser.org>
This commit is contained in:
Daniel Silverstone 2024-05-24 19:44:40 +01:00
parent 9e448ebfcd
commit 74791c0229
1 changed files with 1 additions and 1 deletions

View File

@ -100,7 +100,7 @@ const char *filename_request(void)
i = i % 99;
snprintf(filename_buffer, sizeof(filename_buffer), "%s%.2i", dir->prefix, i);
snprintf(filename_buffer, sizeof(filename_buffer), "%s%.2u", dir->prefix, (unsigned int)i);
return filename_buffer;
}