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

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