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:
Richard W.M. Jones
2021-09-07 15:40:53 +01:00
parent 1e131ea01a
commit f01818fb00

View File

@@ -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);