fix buffer overflow in battery state parsing
"Not charging" is 12 characters; %12[a-zA-Z ] reads up to 12 chars plus a NUL terminator (13 bytes) into a 12-byte buffer. Increase state buffer to 13 in both battery_state and battery_remaining.
This commit is contained in:
parent
4f61bbbd8e
commit
98769dfed7
@ -62,7 +62,7 @@
|
||||
{ "Not charging", "o" },
|
||||
};
|
||||
size_t i;
|
||||
char path[PATH_MAX], state[12];
|
||||
char path[PATH_MAX], state[13];
|
||||
|
||||
if (esnprintf(path, sizeof(path), POWER_SUPPLY_STATUS, bat) < 0)
|
||||
return NULL;
|
||||
@ -81,7 +81,7 @@
|
||||
{
|
||||
uintmax_t charge_now, current_now, m, h;
|
||||
double timeleft;
|
||||
char path[PATH_MAX], state[12];
|
||||
char path[PATH_MAX], state[13];
|
||||
|
||||
if (esnprintf(path, sizeof(path), POWER_SUPPLY_STATUS, bat) < 0)
|
||||
return NULL;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user