Blame SOURCES/e2fsprogs-1.45.6-e2fsck-add-maximum-string-length-specifiers-to-fscan.patch

a77133
From c9d064c7a4e4ffbfaf95098c57381ee5394a1346 Mon Sep 17 00:00:00 2001
a77133
From: Theodore Ts'o <tytso@mit.edu>
a77133
Date: Tue, 10 Aug 2021 15:36:46 -0400
a77133
Subject: [PATCH 45/46] e2fsck: add maximum string length specifiers to fscanf
a77133
 format strings
a77133
Content-Type: text/plain
a77133
a77133
When parsing strings from /proc/apm and /proc/acpi/ac_adapter, add
a77133
string length limits to prevent possible buffer overruns.
a77133
a77133
Addresses-Coverty-Bug: 1297496
a77133
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
a77133
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
a77133
---
a77133
 e2fsck/unix.c | 4 ++--
a77133
 1 file changed, 2 insertions(+), 2 deletions(-)
a77133
a77133
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
a77133
index 15a73e7c..ddd384b1 100644
a77133
--- a/e2fsck/unix.c
a77133
+++ b/e2fsck/unix.c
a77133
@@ -302,7 +302,7 @@ static int is_on_batt(void)
a77133
 	}
a77133
 	f = fopen("/proc/apm", "r");
a77133
 	if (f) {
a77133
-		if (fscanf(f, "%s %s %s %x", tmp, tmp, tmp, &acflag) != 4)
a77133
+		if (fscanf(f, "%79s %79s %79s %x", tmp, tmp, tmp, &acflag) != 4)
a77133
 			acflag = 1;
a77133
 		fclose(f);
a77133
 		return (acflag != 1);
a77133
@@ -318,7 +318,7 @@ static int is_on_batt(void)
a77133
 			f = fopen(fname, "r");
a77133
 			if (!f)
a77133
 				continue;
a77133
-			if (fscanf(f, "%s %s", tmp2, tmp) != 2)
a77133
+			if (fscanf(f, "%79s %79s", tmp2, tmp) != 2)
a77133
 				tmp[0] = 0;
a77133
 			fclose(f);
a77133
 			if (strncmp(tmp, "off-line", 8) == 0) {
a77133
-- 
a77133
2.35.1
a77133