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

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