mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
daemon/xattr.c: Increase size of temporary buffer for %zu
Found by GCC -fanalyzer:
xattr.c:478:32: error: '%zu' directive output may be truncated writing between 1 and 19 bytes into a region of size 16 [-Werror=format-truncation=]
478 | snprintf (num, sizeof num, "%zu", nr_attrs);
| ^
xattr.c:478:32: note: directive argument in the range [0, 2305843009213693950]
/usr/include/bits/stdio2.h:71:10: note: '__builtin___snprintf_chk' output between 2 and 20 bytes into a destination of size 16
71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^
(cherry picked from commit 58599031f8)
This commit is contained in:
@@ -474,7 +474,7 @@ do_internal_lxattrlist (const char *path, char *const *names)
|
||||
}
|
||||
}
|
||||
|
||||
char num[16];
|
||||
char num[32];
|
||||
snprintf (num, sizeof num, "%zu", nr_attrs);
|
||||
entry[0].attrval.attrval_len = strlen (num) + 1;
|
||||
entry[0].attrval.attrval_val = strdup (num);
|
||||
|
||||
Reference in New Issue
Block a user