mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-28 20:02:17 +00:00
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>
This commit is contained in:
parent
93dd0a0978
commit
c078f0dd01
1 changed files with 2 additions and 1 deletions
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue