18039022 Running "/usr/bin/columns --help" crashes with segmentation fault
authorRich Burridge <rich.burridge@oracle.com>
Mon, 13 Jan 2014 08:41:22 -0800
changeset 1636 d3ad0c91bf12
parent 1635 5269c1d79ab0
child 1637 54bd5ac8db85
18039022 Running "/usr/bin/columns --help" crashes with segmentation fault
components/autogen/patches/autoopts-numeric.c.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/autogen/patches/autoopts-numeric.c.patch	Mon Jan 13 08:41:22 2014 -0800
@@ -0,0 +1,41 @@
+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;