Module Name: othersrc
Committed By: agc
Date: Wed Nov 28 06:51:24 UTC 2012
Modified Files:
othersrc/external/bsd/getopt2/dist: getopt2.c
Log Message:
more feedback from fuzz testing round:
check arguments passed to us, return error codes if they're not good.
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/getopt2/dist/getopt2.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: othersrc/external/bsd/getopt2/dist/getopt2.c
diff -u othersrc/external/bsd/getopt2/dist/getopt2.c:1.1.1.1 othersrc/external/bsd/getopt2/dist/getopt2.c:1.2
--- othersrc/external/bsd/getopt2/dist/getopt2.c:1.1.1.1 Fri Jul 15 05:30:48 2011
+++ othersrc/external/bsd/getopt2/dist/getopt2.c Wed Nov 28 06:51:23 2012
@@ -32,6 +32,9 @@
int
getopt2_init(getopt2_t *options)
{
+ if (options == NULL) {
+ return 0;
+ }
(void) memset(options, 0x0, sizeof(*options));
options->optind = 1;
return 1;
@@ -44,6 +47,9 @@ getopt2(getopt2_t *options, int argc, ch
char ch;
int subind;
+ if (options == NULL || argc < 0 || argv == NULL || optstring == NULL) {
+ return -1;
+ }
if (options->optind == 0) {
/* allow for straight getopt2() invocation without init */
getopt2_init(options);