ianh 2002/08/02 09:28:11
Modified: misc/unix getopt.c
Log:
The documentation within include/apr_getopt.h says that the name
argument within the option structure should be NULL if a long name is
not present - but it performs a strlen on that value without checking
for NULL.
Submitted by : David Waite <[EMAIL PROTECTED]>
Revision Changes Path
1.37 +6 -4 apr/misc/unix/getopt.c
Index: getopt.c
===================================================================
RCS file: /home/cvs/apr/misc/unix/getopt.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- getopt.c 2 Aug 2002 16:26:09 -0000 1.36
+++ getopt.c 2 Aug 2002 16:28:11 -0000 1.37
@@ -237,10 +237,12 @@
for (i = 0; ; i++) {
if (opts[i].optch == 0) /* No match */
return serr(os, "invalid option", p - 2, APR_BADCH);
- len = strlen(opts[i].name);
- if (strncmp(p, opts[i].name, len) == 0
- && (p[len] == '\0' || p[len] == '='))
- break;
+ if (opts[i].name) {
+ len = strlen(opts[i].name);
+ if (strncmp(p, opts[i].name, len) == 0
+ && (p[len] == '\0' || p[len] == '='))
+ break;
+ }
}
*optch = opts[i].optch;