Blame SOURCES/0008-Try-to-avoid-covscan-freaking-out-about-sscanf-with-.patch

5fb29d
From 2e40c869df425738ef06e7159a16adf5bf82c548 Mon Sep 17 00:00:00 2001
5fb29d
From: Peter Jones <pjones@redhat.com>
5fb29d
Date: Wed, 10 Sep 2014 15:57:26 -0400
5fb29d
Subject: [PATCH 08/18] Try to avoid covscan freaking out about sscanf with %n.
5fb29d
MIME-Version: 1.0
5fb29d
Content-Type: text/plain; charset=UTF-8
5fb29d
Content-Transfer-Encoding: 8bit
5fb29d
5fb29d
covscan says:
5fb29d
5fb29d
 5. efibootmgr-0.8.0/src/lib/disk.c:96:tainted_data_argument – Calling
5fb29d
 function "fgets(char * restrict, int, FILE * restrict)" taints argument
5fb29d
 "line".
5fb29d
 10. efibootmgr-0.8.0/src/lib/disk.c:103:vararg_transitive – Call to
5fb29d
 "sscanf(char const * restrict, char const * restrict, ...)" with
5fb29d
 tainted argument "line" taints "major".
5fb29d
 11. efibootmgr-0.8.0/src/lib/disk.c:103:vararg_transitive – Call to
5fb29d
 "sscanf(char const * restrict, char const * restrict, ...)" with
5fb29d
 tainted argument "line" taints "scanned".
5fb29d
 13. efibootmgr-0.8.0/src/lib/disk.c:103:tainted_data – Using tainted
5fb29d
 variable "scanned" as an index into an array "line".
5fb29d
5fb29d
I *think* that's really complaining that if sscanf fails before
5fb29d
processing %n, then "scanned" is indeterminate here.  So I've assigned
5fb29d
it to 0.
5fb29d
5fb29d
Either way, if any of that goes wrong, the code's going to completely
5fb29d
fail.
5fb29d
5fb29d
Signed-off-by: Peter Jones <pjones@redhat.com>
5fb29d
---
5fb29d
 src/lib/disk.c | 4 ++--
5fb29d
 1 file changed, 2 insertions(+), 2 deletions(-)
5fb29d
5fb29d
diff --git a/src/lib/disk.c b/src/lib/disk.c
5fb29d
index 904010b..4536a67 100644
5fb29d
--- a/src/lib/disk.c
5fb29d
+++ b/src/lib/disk.c
5fb29d
@@ -56,7 +56,7 @@ get_virtblk_major(void)
5fb29d
 	}
5fb29d
 	while (fgets(line, sizeof line, f) != NULL) {
5fb29d
 		size_t len = strlen(line);
5fb29d
-		int major, scanned;
5fb29d
+		int major, scanned = 0;
5fb29d
 
5fb29d
 		if (len == 0 || line[len - 1] != '\n') {
5fb29d
 			break;
5fb29d
@@ -95,7 +95,7 @@ get_nvme_major(void)
5fb29d
 	}
5fb29d
 	while (fgets(line, sizeof line, f) != NULL) {
5fb29d
 		size_t len = strlen(line);
5fb29d
-		int major, scanned;
5fb29d
+		int major, scanned = 0;
5fb29d
 
5fb29d
 		if (len == 0 || line[len - 1] != '\n') {
5fb29d
 			break;
5fb29d
-- 
5fb29d
1.9.3
5fb29d