80913e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
80913e
From: Darren Kenny <darren.kenny@oracle.com>
80913e
Date: Wed, 21 Oct 2020 14:41:27 +0000
80913e
Subject: [PATCH] gnulib/regexec: Resolve unused variable
80913e
80913e
This is a really minor issue where a variable is being assigned to but
80913e
not checked before it is overwritten again.
80913e
80913e
The reason for this issue is that we are not building with DEBUG set and
80913e
this in turn means that the assert() that reads the value of the
80913e
variable match_last is being processed out.
80913e
80913e
The solution, move the assignment to match_last in to an ifdef DEBUG too.
80913e
80913e
Fixes: CID 292459
80913e
80913e
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
80913e
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
80913e
---
80913e
 grub-core/gnulib/regexec.c              |  4 ++++
80913e
 conf/Makefile.extra-dist                |  1 +
80913e
 grub-core/gnulib-fix-unused-value.patch | 14 ++++++++++++++
80913e
 3 files changed, 19 insertions(+)
80913e
 create mode 100644 grub-core/gnulib-fix-unused-value.patch
80913e
80913e
diff --git a/grub-core/gnulib/regexec.c b/grub-core/gnulib/regexec.c
b32e65
index a7776f088..9264f2628 100644
80913e
--- a/grub-core/gnulib/regexec.c
80913e
+++ b/grub-core/gnulib/regexec.c
80913e
@@ -879,7 +879,11 @@ re_search_internal (const regex_t *preg,
80913e
 		    break;
80913e
 		  if (BE (err != REG_NOMATCH, 0))
80913e
 		    goto free_return;
80913e
+#ifdef DEBUG
80913e
+		  /* Only used for assertion below when DEBUG is set, otherwise
80913e
+		     it will be over-written when we loop around.  */
80913e
 		  match_last = REG_MISSING;
80913e
+#endif
80913e
 		}
80913e
 	      else
80913e
 		break; /* We found a match.  */
80913e
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
b32e65
index 5946ec24a..b53fe6dfd 100644
80913e
--- a/conf/Makefile.extra-dist
80913e
+++ b/conf/Makefile.extra-dist
80913e
@@ -31,6 +31,7 @@ EXTRA_DIST += grub-core/genemuinit.sh
80913e
 EXTRA_DIST += grub-core/genemuinitheader.sh
80913e
 
80913e
 EXTRA_DIST += grub-core/gnulib-fix-null-deref.diff
80913e
+EXTRA_DIST += grub-core/gnulib-fix-unused-value.patch
80913e
 EXTRA_DIST += grub-core/gnulib-fix-width.diff
80913e
 EXTRA_DIST += grub-core/gnulib-no-abort.diff
80913e
 EXTRA_DIST += grub-core/gnulib-no-gets.diff
80913e
diff --git a/grub-core/gnulib-fix-unused-value.patch b/grub-core/gnulib-fix-unused-value.patch
80913e
new file mode 100644
b32e65
index 000000000..452a87329
80913e
--- /dev/null
80913e
+++ b/grub-core/gnulib-fix-unused-value.patch
80913e
@@ -0,0 +1,14 @@
80913e
+--- grub-core/gnulib/regexec.c	2020-10-21 14:25:35.310195912 +0000
80913e
++++ grub-core/gnulib/regexec.c	2020-10-21 14:32:07.961765604 +0000
80913e
+@@ -828,7 +828,11 @@
80913e
+ 		    break;
80913e
+		  if (BE (err != REG_NOMATCH, 0))
80913e
+ 		    goto free_return;
80913e
++#ifdef DEBUG
80913e
++		  /* Only used for assertion below when DEBUG is set, otherwise
80913e
++		     it will be over-written when we loop around.  */
80913e
+		  match_last = REG_MISSING;
80913e
++#endif
80913e
+ 		}
80913e
+ 	      else
80913e
+ 		break; /* We found a match.  */