Blame SOURCES/0001-scheduler-cert.c-Fix-string-comparison-fixes-CVE-202.patch

f65e80
From de4f8c196106033e4c372dce3e91b9d42b0b9444 Mon Sep 17 00:00:00 2001
f65e80
From: Zdenek Dohnal <zdohnal@redhat.com>
f65e80
Date: Thu, 26 May 2022 06:27:04 +0200
f65e80
Subject: [PATCH] scheduler/cert.c: Fix string comparison (fixes
f65e80
 CVE-2022-26691)
f65e80
f65e80
The previous algorithm didn't expect the strings can have a different
f65e80
length, so one string can be a substring of the other and such substring
f65e80
was reported as equal to the longer string.
f65e80
---
f65e80
 CHANGES.md       | 1 +
f65e80
 scheduler/cert.c | 9 ++++++++-
f65e80
 2 files changed, 9 insertions(+), 1 deletion(-)
f65e80
f65e80
diff --git a/scheduler/cert.c b/scheduler/cert.c
f65e80
index b268bf1b2..9b65b96c9 100644
f65e80
--- a/scheduler/cert.c
f65e80
+++ b/scheduler/cert.c
f65e80
@@ -444,5 +444,12 @@ ctcompare(const char *a,		/* I - First string */
f65e80
     b ++;
f65e80
   }
f65e80
 
f65e80
-  return (result);
f65e80
+ /*
f65e80
+  * The while loop finishes when *a == '\0' or *b == '\0'
f65e80
+  * so after the while loop either both *a and *b == '\0',
f65e80
+  * or one points inside a string, so when we apply bitwise OR on *a,
f65e80
+  * *b and result, we get a non-zero return value if the compared strings don't match.
f65e80
+  */
f65e80
+
f65e80
+  return (result | *a | *b);
f65e80
 }
f65e80
-- 
f65e80
2.36.1
f65e80