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

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