nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0393-gnulib-regexec-Resolve-unused-variable.patch

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