Blob Blame History Raw
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Darren Kenny <darren.kenny@oracle.com>
Date: Tue, 24 Nov 2020 18:04:22 +0000
Subject: [PATCH] gnulib/regcomp: Fix uninitialized re_token

This issue has been fixed in the latest version of gnulib, so to
maintain consistency, I've backported that change rather than doing
something different.

Fixes: CID 73828

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/gnulib/regcomp.c                      |  3 +--
 conf/Makefile.extra-dist                        |  1 +
 grub-core/gnulib-fix-regcomp-uninit-token.patch | 12 ++++++++++++
 3 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 grub-core/gnulib-fix-regcomp-uninit-token.patch

diff --git a/grub-core/gnulib/regcomp.c b/grub-core/gnulib/regcomp.c
index de9f62208..6d0830ac6 100644
--- a/grub-core/gnulib/regcomp.c
+++ b/grub-core/gnulib/regcomp.c
@@ -3790,8 +3790,7 @@ static bin_tree_t *
 create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
 	     re_token_type_t type)
 {
-  re_token_t t;
-  t.type = type;
+  re_token_t t = { .type = type };
   return create_token_tree (dfa, left, right, &t);
 }
 
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
index edbe7846e..ee276a877 100644
--- a/conf/Makefile.extra-dist
+++ b/conf/Makefile.extra-dist
@@ -32,6 +32,7 @@ EXTRA_DIST += grub-core/genemuinitheader.sh
 
 EXTRA_DIST += grub-core/gnulib-fix-null-deref.diff
 EXTRA_DIST += grub-core/gnulib-fix-null-state-deref.patch
+EXTRA_DIST += grub-core/gnulib-fix-regcomp-uninit-token.patch
 EXTRA_DIST += grub-core/gnulib-fix-regexec-null-deref.patch
 EXTRA_DIST += grub-core/gnulib-fix-uninit-structure.patch
 EXTRA_DIST += grub-core/gnulib-fix-unused-value.patch
diff --git a/grub-core/gnulib-fix-regcomp-uninit-token.patch b/grub-core/gnulib-fix-regcomp-uninit-token.patch
new file mode 100644
index 000000000..d61574522
--- /dev/null
+++ b/grub-core/gnulib-fix-regcomp-uninit-token.patch
@@ -0,0 +1,12 @@
+--- grub-core/gnulib/regcomp.c
++++ grub-core/gnulib/regcomp.c
+@@ -3808,8 +3808,7 @@ static bin_tree_t *
+ create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
+ 	     re_token_type_t type)
+ {
+-  re_token_t t;
+-  t.type = type;
++  re_token_t t = { .type = type };
+   return create_token_tree (dfa, left, right, &t);
+ }
+