mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
drivers/leds/leds-lp5521.c: fix potential buffer overflow
The code doesn't check first sscanf() return value. If first sscanf() failed then c contains some garbage. It might lead to reading uninitialised stack data in the second sscanf() call. Signed-off-by: Vasiliy Kulikov <[email protected]> Cc: Richard Purdie <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
6db26ffc91
commit
2260209c49
1 changed files with 2 additions and 0 deletions
|
|
@ -373,6 +373,8 @@ static int lp5521_do_store_load(struct lp5521_engine *engine,
|
|||
while ((offset < len - 1) && (i < LP5521_PROGRAM_LENGTH)) {
|
||||
/* separate sscanfs because length is working only for %s */
|
||||
ret = sscanf(buf + offset, "%2s%n ", c, &nrchars);
|
||||
if (ret != 2)
|
||||
goto fail;
|
||||
ret = sscanf(c, "%2x", &cmd);
|
||||
if (ret != 1)
|
||||
goto fail;
|
||||
|
|
|
|||
Loading…
Reference in a new issue