drivers: sbs_gauge: Fix buffer overflow
Fixes buffer overflow when trying to copy 5 bytes to 4 bytes array. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
8bb576b7e8
commit
f6211e2641
|
@ -141,7 +141,8 @@ static int emul_sbs_gauge_buffer_read(const struct emul *target, int reg, char *
|
|||
break;
|
||||
|
||||
case SBS_GAUGE_CMD_DEVICE_CHEMISTRY:
|
||||
dev_chem->device_chemistry_length = sizeof(chem);
|
||||
dev_chem->device_chemistry_length = MIN(sizeof(chem),
|
||||
sizeof(dev_chem->device_chemistry));
|
||||
memcpy(dev_chem->device_chemistry, chem, dev_chem->device_chemistry_length);
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue