Skip to contentSkip to conversation

mpssd: fix buffer overflow warning

PATCH Applied Mike Danese 3 participants 3 messages May 20, 2016 – Jun 3, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpssd: fix buffer overflow warning

The compilation emits a warning in function ‘snprintf’,
inlined from ‘set_cmdline’ at ../Documentation/mic/mpssd/mpssd.c:1541:9:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10:
warning: call to __builtin___snprintf_chk will always overflow destination buffer

This was introduced in commit f4a66c204482 ("misc: mic: Update MIC host daemon with COSM changes") and is fixed by reverting the changes to the size argument of these snprintf statements.

Cc Ashutosh Dixit <[email protected]>
---
 Documentation/mic/mpssd/mpssd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/mic/mpssd/mpssd.c +2 -2
index 30fb842..49db1de 100644
@@ -1538,9 +1538,9 @@ set_cmdline(struct mic_info *mic)
 
 	len = snprintf(buffer, PATH_MAX,
 		"clocksource=tsc highres=off nohz=off ");
-	len += snprintf(buffer + len, PATH_MAX,
+	len += snprintf(buffer + len, PATH_MAX - len,
 		"cpufreq_on;corec6_off;pc3_off;pc6_off ");
-	len += snprintf(buffer + len, PATH_MAX,
+	len += snprintf(buffer + len, PATH_MAX - len,
 		"ifcfg=static;address,172.31.%d.1;netmask,255.255.255.0",
 		mic->id + 1);
 
Signature · 1 line
2.5.0
#1 lore raw
Quoted 10 lines · Mike Danese

The compilation emits a warning in function ‘snprintf’,
inlined from ‘set_cmdline’ at ../Documentation/mic/mpssd/mpssd.c:1541:9:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10:
warning: call to __builtin___snprintf_chk will always overflow destination buffer

This was introduced in commit f4a66c204482 ("misc: mic: Update MIC host daemon with COSM changes") and is fixed by reverting the changes to the size argument of these snprintf statements.

Thanks for the patch, the fix is fine.

maintainer Applied
#2 lore raw
In reply to Mike Danese
Quoted 6 lines · On Thu, 19 May 2016 21:54:51 -0700 Mike Danese <[email protected]> wrote:

The compilation emits a warning in function ‘snprintf’,
inlined from ‘set_cmdline’ at ../Documentation/mic/mpssd/mpssd.c:1541:9:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10:
warning: call to __builtin___snprintf_chk will always overflow destination buffer

Applied to the docs tree, thanks. I do wonder if Documentation/ is the best place for this tool, though...

jon