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 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)