mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-12 15:24:00 +08:00
arch: s390: appldata: using strncpy() and strnlen() instead of sprintf()
'buf[2]' is 2 bytes length, and sprintf() will append '\0' at the end of string "?\n", so original implementation is memory overflow. Need use strncpy() and strnlen() instead of sprintf(). Signed-off-by: Chen Gang <gang.chen@asianux.com> Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
9acf73b7d0
commit
d5b4c2f493
@ -212,7 +212,9 @@ appldata_timer_handler(ctl_table *ctl, int write,
|
||||
return 0;
|
||||
}
|
||||
if (!write) {
|
||||
len = sprintf(buf, appldata_timer_active ? "1\n" : "0\n");
|
||||
strncpy(buf, appldata_timer_active ? "1\n" : "0\n",
|
||||
ARRAY_SIZE(buf));
|
||||
len = strnlen(buf, ARRAY_SIZE(buf));
|
||||
if (len > *lenp)
|
||||
len = *lenp;
|
||||
if (copy_to_user(buffer, buf, len))
|
||||
@ -317,7 +319,8 @@ appldata_generic_handler(ctl_table *ctl, int write,
|
||||
return 0;
|
||||
}
|
||||
if (!write) {
|
||||
len = sprintf(buf, ops->active ? "1\n" : "0\n");
|
||||
strncpy(buf, ops->active ? "1\n" : "0\n", ARRAY_SIZE(buf));
|
||||
len = strnlen(buf, ARRAY_SIZE(buf));
|
||||
if (len > *lenp)
|
||||
len = *lenp;
|
||||
if (copy_to_user(buffer, buf, len)) {
|
||||
|
Loading…
Reference in New Issue
Block a user