svn commit: trunk/busybox/libbb
vda at busybox.net
vda at busybox.net
Wed Nov 12 22:06:47 UTC 2008
Author: vda
Date: 2008-11-12 14:06:46 -0800 (Wed, 12 Nov 2008)
New Revision: 24022
Log:
gzip: fix gzip -dc case caused by using stale getopt state
Modified:
trunk/busybox/libbb/getopt32.c
Changeset:
Modified: trunk/busybox/libbb/getopt32.c
===================================================================
--- trunk/busybox/libbb/getopt32.c 2008-11-12 21:37:19 UTC (rev 24021)
+++ trunk/busybox/libbb/getopt32.c 2008-11-12 22:06:46 UTC (rev 24022)
@@ -155,9 +155,9 @@
Allows any arguments to be given without a dash (./program w x)
as well as with a dash (./program -x).
- NB: getopt32() will leak a small amount of memory if you use
- this option! Do not use it if there is a possibility of recursive
- getopt32() calls.
+ NB: getopt32() will leak a small amount of memory if you use
+ this option! Do not use it if there is a possibility of recursive
+ getopt32() calls.
"--" A double dash at the beginning of opt_complementary means the
argv[1] string should always be treated as options, even if it isn't
@@ -165,9 +165,9 @@
such as "ar" and "tar":
tar xvf foo.tar
- NB: getopt32() will leak a small amount of memory if you use
- this option! Do not use it if there is a possibility of recursive
- getopt32() calls.
+ NB: getopt32() will leak a small amount of memory if you use
+ this option! Do not use it if there is a possibility of recursive
+ getopt32() calls.
"-N" A dash as the first char in a opt_complementary group followed
by a single digit (0-9) means that at least N non-option
@@ -515,6 +515,19 @@
}
}
+ /* In case getopt32 was already called:
+ * reset the libc getopt() function, which keeps internal state.
+ * run_nofork_applet_prime() does this, but we might end up here
+ * also via gunzip_main() -> gzip_main(). Play safe.
+ */
+#ifdef __GLIBC__
+ optind = 0;
+#else /* BSD style */
+ optind = 1;
+ /* optreset = 1; */
+#endif
+ /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */
+
pargv = NULL;
/* Note: just "getopt() <= 0" will not work well for
More information about the busybox-cvs
mailing list