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