Whamcloud - gitweb
git://git.whamcloud.com
/
tools
/
e2fsprogs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
95954ac
)
e2fsck: add maximum string length specifiers to fscanf format strings
author
Theodore Ts'o
<tytso@mit.edu>
Tue, 10 Aug 2021 19:36:46 +0000
(15:36 -0400)
committer
Theodore Ts'o
<tytso@mit.edu>
Tue, 10 Aug 2021 19:36:46 +0000
(15:36 -0400)
When parsing strings from /proc/apm and /proc/acpi/ac_adapter, add
string length limits to prevent possible buffer overruns.
Addresses-Coverty-Bug: 1297496
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/unix.c
patch
|
blob
|
history
diff --git
a/e2fsck/unix.c
b/e2fsck/unix.c
index
c5f9e44
..
f267bae
100644
(file)
--- a/
e2fsck/unix.c
+++ b/
e2fsck/unix.c
@@
-304,7
+304,7
@@
static int is_on_batt(void)
}
f = fopen("/proc/apm", "r");
if (f) {
- if (fscanf(f, "%
s %s %
s %x", tmp, tmp, tmp, &acflag) != 4)
+ if (fscanf(f, "%
79s %79s %79
s %x", tmp, tmp, tmp, &acflag) != 4)
acflag = 1;
fclose(f);
return (acflag != 1);
@@
-320,7
+320,7
@@
static int is_on_batt(void)
f = fopen(fname, "r");
if (!f)
continue;
- if (fscanf(f, "%
s %
s", tmp2, tmp) != 2)
+ if (fscanf(f, "%
79s %79
s", tmp2, tmp) != 2)
tmp[0] = 0;
fclose(f);
if (strncmp(tmp, "off-line", 8) == 0) {