IB/hfi1: Fix potential buffer overflow
authorTadeusz Struk <tadeusz.struk@intel.com>
Thu, 9 Jun 2016 14:51:51 +0000 (07:51 -0700)
committerDoug Ledford <dledford@redhat.com>
Sat, 18 Jun 2016 00:11:27 +0000 (20:11 -0400)
This fixes potential buffer overflow because the sprintf function
doesn't check buffer boundaries. Use snprintf instead.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/qsfp.c

index 2441669f0817dbec51c7fbcdc847c0bff9f48bfb..9fb561682c661b92e2a09beca2b53daf9f8c5b5e 100644 (file)
@@ -579,7 +579,8 @@ int qsfp_dump(struct hfi1_pportdata *ppd, char *buf, int len)
 
        if (ppd->qsfp_info.cache_valid) {
                if (QSFP_IS_CU(cache[QSFP_MOD_TECH_OFFS]))
-                       sprintf(lenstr, "%dM ", cache[QSFP_MOD_LEN_OFFS]);
+                       snprintf(lenstr, sizeof(lenstr), "%dM ",
+                                cache[QSFP_MOD_LEN_OFFS]);
 
                power_byte = cache[QSFP_MOD_PWR_OFFS];
                sofar += scnprintf(buf + sofar, len - sofar, "PWR:%.3sW\n",
This page took 0.02677 seconds and 5 git commands to generate.