Skip to content

Commit 8288028

Browse files
trofijpoimboe
authored andcommitted
objtool: Fix truncated string warning
On GCC 12, the build fails due to a possible truncated string: check.c: In function 'validate_call': check.c:2865:58: error: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=] 2865 | snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx); | ^~ In theory it's a valid bug: static char pvname[16]; int idx; ... idx = (rel->addend / sizeof(void *)); snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx); There are only 7 chars for %d while it could take up to 9, so the printed "pv_ops[%d]" string could get truncated. In reality the bug should never happen, because pv_ops only has ~80 entries, so 7 chars for the integer is more than enough. Still, it's worth fixing. Bump the buffer size by 2 bytes to silence the warning. [ jpoimboe: changed size to 19; massaged changelog ] Fixes: db2b0c5 ("objtool: Support pv_opsindirect calls for noinstr") Reported-by: Adam Borowski <[email protected]> Reported-by: Martin Liška <[email protected]> Signed-off-by: Sergei Trofimovich <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e783362 commit 8288028

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/objtool/check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2854,7 +2854,7 @@ static inline bool func_uaccess_safe(struct symbol *func)
28542854

28552855
static inline const char *call_dest_name(struct instruction *insn)
28562856
{
2857-
static char pvname[16];
2857+
static char pvname[19];
28582858
struct reloc *rel;
28592859
int idx;
28602860

0 commit comments

Comments
 (0)