Hi there! :-)

I've fixed the crash. It was a segmentation fault due to a faulty implementation of a command-line options parser.

The command line parser accessed invalid memory when a given option matched several option definitions as a prefix, but none of them exactly (e.g. "--s" as option with "--sam" and "--samfrac" as option definitions). This was due to an incorrect check of exact matching that tried to access "opt[i].name" with i being greater than the upper bound of the array "opt" in case of not having an exact match. Replaced it with the proper check.

Please find the patch attached.

I couldn't forward the patch to upstream because there doesn't seem to be an upstream any more... :-/

Cheers,
Martin

Description: Fix segmentation fault with ambiguous arguments
 The command line parser accessed invalid memory when a given
 option matched several option definitions as a prefix, but none
 of them exactly (e.g. "--s" as option with "--sam" and
 "--samfrac" as option definitions). This was due to an incorrect
 check of exact matching that tried to access "opt[i].name" with
 i being greater than the upper bound of the array "opt" in case
 of not having an exact match. Replaced it with the proper check.
Author: Martin Steghöfer <mar...@steghoefer.eu>
Bug-Debian: http://bugs.debian.org/716353

--- a/getopt.c
+++ b/getopt.c
@@ -109,7 +109,8 @@
 	    opti = i;
 	    if (arglen == strlen(opt[i].name)) break; /* exact match, stop now */
 	  }
-      if (nmatch > 1 && arglen != strlen(opt[i].name)) 
+      if (nmatch > 1 // got several prefix matches
+	    && i == nopts) // with none of them being an exact match
 	Die("Option \"%s\" is ambiguous; please be more specific.\n%s",
 	    argv[optind], usage);
       if (nmatch == 0)

Reply via email to