components/autogen/patches/autoopts-numeric.c.patch
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Mon, 03 Mar 2014 23:00:33 -0800
changeset 1741 8e31d13070e7
parent 1636 d3ad0c91bf12
permissions -rw-r--r--
Added tag s12-43 for changeset d5b2d81eeedc

Prevent "/usr/bin/columns --help" from crashing.

This problem has been reported upstream and fixed in a future autogen
release. The autogen maintainer says:

"This is a very long standing bug that I'm surprised hasn't surfaced before:

In autoopts/numeric.c we have:

    /*
     *  Numeric options may have a range associated with it.
     *  If it does, the usage procedure requests that it be
     *  emitted by passing a NULL od pointer.  Also bail out
     *  if there is no option argument or if we are being reset.
     */
    if (  (od == NULL)
       || (od->optArg.argString == NULL)
       || ((od->fOptState & OPTST_RESET) != 0))
        return;

    errno = 0;
    val = strtol(od->optArg.argString, &pz, 0);

Another condition for that bail-out needs to be whether or not
the "argString" has just been set.  It has not been in this case
because we are trying to tease out some usage information."

This patch is based on the solution provided by the autogen maintainer.

--- autogen-5.16.2/autoopts/numeric.c.orig	2014-01-09 12:50:03.575210189 -0800
+++ autogen-5.16.2/autoopts/numeric.c	2014-01-09 13:08:29.709753147 -0800
@@ -111,7 +111,8 @@
      */
     if (  (pOD == NULL)
        || (pOD->optArg.argString == NULL)
-       || ((pOD->fOptState & OPTST_RESET) != 0))
+       || ((pOD->fOptState & OPTST_RESET) != 0)
+       || (pOpts <= OPTPROC_EMIT_LIMIT))
         return;
 
     errno = 0;