Blame SOURCES/0052-update-common-submodule-for-CVE-2022-2211-fix.patch

183ea2
From 5852b85eaa174dfb87ce7a03b9f70e2bffac4ca4 Mon Sep 17 00:00:00 2001
183ea2
From: Laszlo Ersek <lersek@redhat.com>
183ea2
Date: Wed, 29 Jun 2022 15:44:27 +0200
183ea2
Subject: [PATCH] update common submodule for CVE-2022-2211 fix
183ea2
183ea2
$ git shortlog 9e990f3e4530..35467027f657
183ea2
183ea2
Laszlo Ersek (1):
183ea2
      options: fix buffer overflow in get_keys() [CVE-2022-2211]
183ea2
183ea2
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
183ea2
(cherry picked from commit 795d5dfcef77fc54fec4d237bda28571454a6d4e)
183ea2
---
183ea2
 common | 2 +-
183ea2
 1 file changed, 1 insertion(+), 1 deletion(-)
183ea2
183ea2
Submodule common be09523d..1174b443:
183ea2
diff --git a/common/options/keys.c b/common/options/keys.c
183ea2
index 798315c..d27a712 100644
183ea2
--- a/common/options/keys.c
183ea2
+++ b/common/options/keys.c
183ea2
@@ -128,17 +128,23 @@ read_first_line_from_file (const char *filename)
183ea2
 char **
183ea2
 get_keys (struct key_store *ks, const char *device, const char *uuid)
183ea2
 {
183ea2
-  size_t i, j, len;
183ea2
+  size_t i, j, nmemb;
183ea2
   char **r;
183ea2
   char *s;
183ea2
 
183ea2
   /* We know the returned list must have at least one element and not
183ea2
    * more than ks->nr_keys.
183ea2
    */
183ea2
-  len = 1;
183ea2
-  if (ks)
183ea2
-    len = MIN (1, ks->nr_keys);
183ea2
-  r = calloc (len+1, sizeof (char *));
183ea2
+  nmemb = 1;
183ea2
+  if (ks && ks->nr_keys > nmemb)
183ea2
+    nmemb = ks->nr_keys;
183ea2
+
183ea2
+  /* make room for the terminating NULL */
183ea2
+  if (nmemb == (size_t)-1)
183ea2
+    error (EXIT_FAILURE, 0, _("size_t overflow"));
183ea2
+  nmemb++;
183ea2
+
183ea2
+  r = calloc (nmemb, sizeof (char *));
183ea2
   if (r == NULL)
183ea2
     error (EXIT_FAILURE, errno, "calloc");
183ea2
 
183ea2
-- 
183ea2
2.31.1
183ea2