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

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