]> Savannah Git Hosting - gnulib.git/commitdiff
argp: Avoid possible NULL access in argp_help.
authorDarren Kenny <darren.kenny@oracle.com>
Fri, 18 Jun 2021 17:32:00 +0000 (19:32 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 18 Jun 2021 17:33:35 +0000 (19:33 +0200)
Reported by Coverity. The invocation chain is:
argp_help -> _help -> fill_in_uparams -> validate_uparams.

* lib/argp-help.c (validate_uparams): Don't crash if state == NULL.

ChangeLog
lib/argp-help.c

index 7eb9befcc6ba8cafd0460d903ef1fc84211b0116..6b4951cc73f6b06825264d8309a6787000015fc7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-18  Darren Kenny  <darren.kenny@oracle.com>  (tiny change)
+
+       argp: Avoid possible NULL access in argp_help.
+       Reported by Coverity. The invocation chain is:
+       argp_help -> _help -> fill_in_uparams -> validate_uparams.
+       * lib/argp-help.c (validate_uparams): Don't crash if state == NULL.
+
 2021-06-16  Bruno Haible  <bruno@clisp.org>
 
        tsearch: Relicense under LGPLv2+.
index 4c89697bdd0518c516ba2ff15cdaa89553082e3c..80cdb44937d3a20b42ad97b0364843d17d487145 100644 (file)
@@ -147,7 +147,8 @@ validate_uparams (const struct argp_state *state, struct uparams *upptr)
       if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin)
         {
           __argp_failure (state, 0, 0,
-                          dgettext (state->root_argp->argp_domain,
+                          dgettext (state == NULL ? NULL
+                                    : state->root_argp->argp_domain,
                                     "\
 ARGP_HELP_FMT: %s value is less than or equal to %s"),
                           "rmargin", up->name);