xref: /OK3568_Linux_fs/buildroot/boot/grub2/0055-gnulib-regexec-Resolve-unused-variable.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From a983d36bd9178d377d2072fd4b11c635fdc404b4 Mon Sep 17 00:00:00 2001
2From: Darren Kenny <darren.kenny@oracle.com>
3Date: Wed, 21 Oct 2020 14:41:27 +0000
4Subject: [PATCH] gnulib/regexec: Resolve unused variable
5
6This is a really minor issue where a variable is being assigned to but
7not checked before it is overwritten again.
8
9The reason for this issue is that we are not building with DEBUG set and
10this in turn means that the assert() that reads the value of the
11variable match_last is being processed out.
12
13The solution, move the assignment to match_last in to an ifdef DEBUG too.
14
15Fixes: CID 292459
16
17Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
18Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
19[Add changes to generated files]
20Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
21---
22 Makefile.in                                         |  1 +
23 conf/Makefile.extra-dist                            |  1 +
24 grub-core/lib/gnulib-patches/fix-unused-value.patch | 14 ++++++++++++++
25 grub-core/lib/gnulib/regexec.c                      |  4 ++++
26 4 files changed, 20 insertions(+)
27 create mode 100644 grub-core/lib/gnulib-patches/fix-unused-value.patch
28
29diff --git a/Makefile.in b/Makefile.in
30index ecb3278..e6b287b 100644
31--- a/Makefile.in
32+++ b/Makefile.in
33@@ -2742,6 +2742,7 @@ EXTRA_DIST = autogen.sh geninit.sh gentpl.py Makefile.util.def \
34 	grub-core/gensyminfo.sh.in grub-core/gensymlist.sh \
35 	grub-core/genemuinit.sh grub-core/genemuinitheader.sh \
36 	grub-core/lib/gnulib-patches/fix-null-deref.patch \
37+	grub-core/lib/gnulib-patches/fix-unused-value.patch \
38 	grub-core/lib/gnulib-patches/fix-width.patch \
39 	grub-core/lib/gnulib-patches/no-abort.patch \
40 	grub-core/lib/libgcrypt \
41diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
42index 46c4e95..9b01152 100644
43--- a/conf/Makefile.extra-dist
44+++ b/conf/Makefile.extra-dist
45@@ -29,6 +29,7 @@ EXTRA_DIST += grub-core/genemuinit.sh
46 EXTRA_DIST += grub-core/genemuinitheader.sh
47
48 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch
49+EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch
50 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch
51 EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch
52
53diff --git a/grub-core/lib/gnulib-patches/fix-unused-value.patch b/grub-core/lib/gnulib-patches/fix-unused-value.patch
54new file mode 100644
55index 0000000..ba51f1b
56--- /dev/null
57+++ b/grub-core/lib/gnulib-patches/fix-unused-value.patch
58@@ -0,0 +1,14 @@
59+--- a/lib/regexec.c	2020-10-21 14:25:35.310195912 +0000
60++++ b/lib/regexec.c	2020-10-21 14:32:07.961765604 +0000
61+@@ -828,7 +828,11 @@
62+ 		    break;
63+ 		  if (__glibc_unlikely (err != REG_NOMATCH))
64+ 		    goto free_return;
65++#ifdef DEBUG
66++		  /* Only used for assertion below when DEBUG is set, otherwise
67++		     it will be over-written when we loop around.  */
68+ 		  match_last = -1;
69++#endif
70+ 		}
71+ 	      else
72+ 		break; /* We found a match.  */
73diff --git a/grub-core/lib/gnulib/regexec.c b/grub-core/lib/gnulib/regexec.c
74index 21cf791..98a25f5 100644
75--- a/grub-core/lib/gnulib/regexec.c
76+++ b/grub-core/lib/gnulib/regexec.c
77@@ -828,6 +828,10 @@ re_search_internal (const regex_t *preg, const char *string, Idx length,
78 		    break;
79 		  if (__glibc_unlikely (err != REG_NOMATCH))
80 		    goto free_return;
81+#ifdef DEBUG
82+		  /* Only used for assertion below when DEBUG is set, otherwise
83+		     it will be over-written when we loop around.  */
84+#endif
85 		  match_last = -1;
86 		}
87 	      else
88--
892.14.2
90
91