nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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