diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2016-06-09 17:51:51 +0300 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-06-18 03:11:27 +0300 |
commit | c078f0dd01b73c70b92a660cb1ce3dfc3cbf2903 (patch) | |
tree | a4bccde38f9e65ee6c11a48bbd435af8e2a2609f /drivers/infiniband/hw | |
parent | 93dd0a097859a174817ea94ec55bfc29c5706454 (diff) | |
download | linux-c078f0dd01b73c70b92a660cb1ce3dfc3cbf2903.tar.xz |
IB/hfi1: Fix potential buffer overflow
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>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r-- | drivers/infiniband/hw/hfi1/qsfp.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/hfi1/qsfp.c b/drivers/infiniband/hw/hfi1/qsfp.c index 2441669f0817..9fb561682c66 100644 --- a/drivers/infiniband/hw/hfi1/qsfp.c +++ b/drivers/infiniband/hw/hfi1/qsfp.c @@ -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", |