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

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