mpssd: fix buffer overflow warning
authorMike Danese <mikedanese@google.com>
Fri, 20 May 2016 04:54:51 +0000 (21:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 24 Sep 2016 08:07:42 +0000 (10:07 +0200)
commit 3610a2add39365a0f153154c60169a66c616d50f upstream.

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 <ashutosh.dixit@intel.com>
Signed-off-by: Mike Danese <mikedanese@google.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/mic/mpssd/mpssd.c

index aaeafa18d99bb70bee8cf5bd1d39829b17d6d3d4..c99a75968c011ef802e184f91255842c0b672608 100644 (file)
@@ -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);