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

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