This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/14896] New: getopt_long: optind contains invalid index in very specific cases
- From: "miguel.a.guedes at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Fri, 30 Nov 2012 12:18:17 +0000
- Subject: [Bug libc/14896] New: getopt_long: optind contains invalid index in very specific cases
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=14896
Bug #: 14896
Summary: getopt_long: optind contains invalid index in very
specific cases
Product: glibc
Version: 2.15
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: unassigned@sourceware.org
ReportedBy: miguel.a.guedes@gmail.com
CC: drepper.fsp@gmail.com
Classification: Unclassified
Created attachment 6765
--> http://sourceware.org/bugzilla/attachment.cgi?id=6765
Test source file that reproduces the bug
This bug affects getopt_long.
In very specific circumstances, optind points to the wrong option when a long
option is not recognised or is invalid.
I've attached a simple test program that reproduces the bug.
Run it like so, ie:
$ gcc test.c -o test && ./test --add -a no_arg lone-value --this-is-long
option add
option a
invalid option: lone-value
non-option ARGV-elements: lone-value
In the example above, getopt_long's internal optind should have skipped
`lone-value' and be pointing at the invalid option `this-is-long'.
Attached source file makes this much clearer.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.