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