Blame SOURCES/0395-gnulib-argp-help-Fix-dereference-of-a-possibly-NULL-.patch

9723a8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
9723a8
From: Darren Kenny <darren.kenny@oracle.com>
9723a8
Date: Wed, 28 Oct 2020 14:43:01 +0000
9723a8
Subject: [PATCH] gnulib/argp-help: Fix dereference of a possibly NULL state
9723a8
9723a8
All other instances of call to __argp_failure() where there is
9723a8
a dgettext() call is first checking whether state is NULL before
9723a8
attempting to dereference it to get the root_argp->argp_domain.
9723a8
9723a8
Fixes: CID 292436
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/argp-help.c                |  3 ++-
9723a8
 conf/Makefile.extra-dist                    |  1 +
9723a8
 grub-core/gnulib-fix-null-state-deref.patch | 12 ++++++++++++
9723a8
 3 files changed, 15 insertions(+), 1 deletion(-)
9723a8
 create mode 100644 grub-core/gnulib-fix-null-state-deref.patch
9723a8
9723a8
diff --git a/grub-core/gnulib/argp-help.c b/grub-core/gnulib/argp-help.c
b71686
index b9be63f40..8af8be073 100644
9723a8
--- a/grub-core/gnulib/argp-help.c
9723a8
+++ b/grub-core/gnulib/argp-help.c
9723a8
@@ -145,7 +145,8 @@ validate_uparams (const struct argp_state *state, struct uparams *upptr)
9723a8
       if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin)
9723a8
         {
9723a8
           __argp_failure (state, 0, 0,
9723a8
-                          dgettext (state->root_argp->argp_domain,
9723a8
+                          dgettext (state == NULL ? NULL
9723a8
+                                    : state->root_argp->argp_domain,
9723a8
                                     "\
9723a8
 ARGP_HELP_FMT: %s value is less than or equal to %s"),
9723a8
                           "rmargin", up->name);
9723a8
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
b71686
index 883baba56..06606de8d 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-null-state-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-null-state-deref.patch b/grub-core/gnulib-fix-null-state-deref.patch
9723a8
new file mode 100644
b71686
index 000000000..813ec09c8
9723a8
--- /dev/null
9723a8
+++ b/grub-core/gnulib-fix-null-state-deref.patch
9723a8
@@ -0,0 +1,12 @@
9723a8
+--- a/lib/argp-help.c	2020-10-28 14:32:19.189215988 +0000
9723a8
++++ b/lib/argp-help.c	2020-10-28 14:38:21.204673940 +0000
9723a8
+@@ -145,7 +145,8 @@
9723a8
+       if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin)
9723a8
+         {
9723a8
+           __argp_failure (state, 0, 0,
9723a8
+-                          dgettext (state->root_argp->argp_domain,
9723a8
++                          dgettext (state == NULL ? NULL
9723a8
++                                    : state->root_argp->argp_domain,
9723a8
+                                     "\
9723a8
+ ARGP_HELP_FMT: %s value is less than or equal to %s"),
9723a8
+                           "rmargin", up->name);