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

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