Skip to content

Commit a508ef4

Browse files
Bartosz Golaszewskikees
authored andcommitted
lib: string_helpers: silence snprintf() output truncation warning
The output of ".%03u" with the unsigned int in range [0, 4294966295] may get truncated if the target buffer is not 12 bytes. This can't really happen here as the 'remainder' variable cannot exceed 999 but the compiler doesn't know it. To make it happy just increase the buffer to where the warning goes away. Fixes: 3c9f368 ("[SCSI] lib: add generic helper to print sizes rounded to the correct SI range") Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Cc: James E.J. Bottomley <[email protected]> Cc: Kees Cook <[email protected]> Cc: [email protected] Signed-off-by: Andrew Morton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 6c06f6a commit a508ef4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/string_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int string_get_size(u64 size, u64 blk_size, const enum string_size_units units,
5757
static const unsigned int rounding[] = { 500, 50, 5 };
5858
int i = 0, j;
5959
u32 remainder = 0, sf_cap;
60-
char tmp[8];
60+
char tmp[12];
6161
const char *unit;
6262

6363
tmp[0] = '\0';

0 commit comments

Comments
 (0)