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

b1bcb2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b1bcb2
From: Darren Kenny <darren.kenny@oracle.com>
b1bcb2
Date: Wed, 28 Oct 2020 14:43:01 +0000
b1bcb2
Subject: [PATCH] gnulib/argp-help: Fix dereference of a possibly NULL state
b1bcb2
b1bcb2
All other instances of call to __argp_failure() where there is
b1bcb2
a dgettext() call is first checking whether state is NULL before
b1bcb2
attempting to dereference it to get the root_argp->argp_domain.
b1bcb2
b1bcb2
Fixes: CID 292436
b1bcb2
b1bcb2
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
b1bcb2
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
b1bcb2
---
b1bcb2
 grub-core/gnulib/argp-help.c                |  3 ++-
b1bcb2
 conf/Makefile.extra-dist                    |  1 +
b1bcb2
 grub-core/gnulib-fix-null-state-deref.patch | 12 ++++++++++++
b1bcb2
 3 files changed, 15 insertions(+), 1 deletion(-)
b1bcb2
 create mode 100644 grub-core/gnulib-fix-null-state-deref.patch
b1bcb2
b1bcb2
diff --git a/grub-core/gnulib/argp-help.c b/grub-core/gnulib/argp-help.c
b1bcb2
index 2914f4723c6..1b21c3500db 100644
b1bcb2
--- a/grub-core/gnulib/argp-help.c
b1bcb2
+++ b/grub-core/gnulib/argp-help.c
b1bcb2
@@ -145,7 +145,8 @@ validate_uparams (const struct argp_state *state, struct uparams *upptr)
b1bcb2
       if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin)
b1bcb2
         {
b1bcb2
           __argp_failure (state, 0, 0,
b1bcb2
-                          dgettext (state->root_argp->argp_domain,
b1bcb2
+                          dgettext (state == NULL ? NULL
b1bcb2
+                                    : state->root_argp->argp_domain,
b1bcb2
                                     "\
b1bcb2
 ARGP_HELP_FMT: %s value is less than or equal to %s"),
b1bcb2
                           "rmargin", up->name);
b1bcb2
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
b1bcb2
index 8baa6a831f7..c3506afe792 100644
b1bcb2
--- a/conf/Makefile.extra-dist
b1bcb2
+++ b/conf/Makefile.extra-dist
b1bcb2
@@ -27,6 +27,7 @@ EXTRA_DIST += grub-core/genemuinit.sh
b1bcb2
 EXTRA_DIST += grub-core/genemuinitheader.sh
b1bcb2
 
b1bcb2
 EXTRA_DIST += grub-core/gnulib-fix-null-deref.diff
b1bcb2
+EXTRA_DIST += grub-core/gnulib-fix-null-state-deref.patch
b1bcb2
 EXTRA_DIST += grub-core/gnulib-fix-uninit-structure.patch
b1bcb2
 EXTRA_DIST += grub-core/gnulib-fix-unused-value.patch
b1bcb2
 EXTRA_DIST += grub-core/gnulib-fix-width.diff
b1bcb2
diff --git a/grub-core/gnulib-fix-null-state-deref.patch b/grub-core/gnulib-fix-null-state-deref.patch
b1bcb2
new file mode 100644
b1bcb2
index 00000000000..813ec09c8a1
b1bcb2
--- /dev/null
b1bcb2
+++ b/grub-core/gnulib-fix-null-state-deref.patch
b1bcb2
@@ -0,0 +1,12 @@
b1bcb2
+--- a/lib/argp-help.c	2020-10-28 14:32:19.189215988 +0000
b1bcb2
++++ b/lib/argp-help.c	2020-10-28 14:38:21.204673940 +0000
b1bcb2
+@@ -145,7 +145,8 @@
b1bcb2
+       if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin)
b1bcb2
+         {
b1bcb2
+           __argp_failure (state, 0, 0,
b1bcb2
+-                          dgettext (state->root_argp->argp_domain,
b1bcb2
++                          dgettext (state == NULL ? NULL
b1bcb2
++                                    : state->root_argp->argp_domain,
b1bcb2
+                                     "\
b1bcb2
+ ARGP_HELP_FMT: %s value is less than or equal to %s"),
b1bcb2
+                           "rmargin", up->name);