nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0396-gnulib-regexec-Fix-possible-null-dereference.patch

80913e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
80913e
From: Darren Kenny <darren.kenny@oracle.com>
80913e
Date: Thu, 5 Nov 2020 10:57:14 +0000
80913e
Subject: [PATCH] gnulib/regexec: Fix possible null-dereference
80913e
80913e
It appears to be possible that the mctx->state_log field may be NULL,
80913e
and the name of this function, clean_state_log_if_needed(), suggests
80913e
that it should be checking that it is valid to be cleaned before
80913e
assuming that it does.
80913e
80913e
Fixes: CID 86720
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                    |  3 +++
80913e
 conf/Makefile.extra-dist                      |  1 +
80913e
 grub-core/gnulib-fix-regexec-null-deref.patch | 12 ++++++++++++
80913e
 3 files changed, 16 insertions(+)
80913e
 create mode 100644 grub-core/gnulib-fix-regexec-null-deref.patch
80913e
80913e
diff --git a/grub-core/gnulib/regexec.c b/grub-core/gnulib/regexec.c
80913e
index 9264f262893..fdacff12ce3 100644
80913e
--- a/grub-core/gnulib/regexec.c
80913e
+++ b/grub-core/gnulib/regexec.c
80913e
@@ -1754,6 +1754,9 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
80913e
 {
80913e
   Idx top = mctx->state_log_top;
80913e
 
80913e
+  if (mctx->state_log == NULL)
80913e
+    return REG_NOERROR;
80913e
+
80913e
   if ((next_state_log_idx >= mctx->input.bufs_len
80913e
        && mctx->input.bufs_len < mctx->input.len)
80913e
       || (next_state_log_idx >= mctx->input.valid_len
80913e
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
80913e
index 06606de8d19..edbe7846eb1 100644
80913e
--- a/conf/Makefile.extra-dist
80913e
+++ b/conf/Makefile.extra-dist
80913e
@@ -32,6 +32,7 @@ EXTRA_DIST += grub-core/genemuinitheader.sh
80913e
 
80913e
 EXTRA_DIST += grub-core/gnulib-fix-null-deref.diff
80913e
 EXTRA_DIST += grub-core/gnulib-fix-null-state-deref.patch
80913e
+EXTRA_DIST += grub-core/gnulib-fix-regexec-null-deref.patch
80913e
 EXTRA_DIST += grub-core/gnulib-fix-uninit-structure.patch
80913e
 EXTRA_DIST += grub-core/gnulib-fix-unused-value.patch
80913e
 EXTRA_DIST += grub-core/gnulib-fix-width.diff
80913e
diff --git a/grub-core/gnulib-fix-regexec-null-deref.patch b/grub-core/gnulib-fix-regexec-null-deref.patch
80913e
new file mode 100644
80913e
index 00000000000..db6dac9c9e3
80913e
--- /dev/null
80913e
+++ b/grub-core/gnulib-fix-regexec-null-deref.patch
80913e
@@ -0,0 +1,12 @@
80913e
+--- a/lib/regexec.c	2020-10-21 14:25:35.310195912 +0000
80913e
++++ b/lib/regexec.c	2020-11-05 10:55:09.621542984 +0000
80913e
+@@ -1692,6 +1692,9 @@
80913e
+ {
80913e
+   Idx top = mctx->state_log_top;
80913e
+
80913e
++  if (mctx->state_log == NULL)
80913e
++    return REG_NOERROR;
80913e
++
80913e
+   if ((next_state_log_idx >= mctx->input.bufs_len
80913e
+        && mctx->input.bufs_len < mctx->input.len)
80913e
+       || (next_state_log_idx >= mctx->input.valid_len