summaryrefslogtreecommitdiffstats
path: root/usr.bin/whereis
diff options
context:
space:
mode:
authorjohan <johan@FreeBSD.org>2002-08-18 18:21:18 +0000
committerjohan <johan@FreeBSD.org>2002-08-18 18:21:18 +0000
commit28378cc9b0121596ba0047e10887e682677ce47d (patch)
tree8564a25b8be7350487211e8847f46bac5a4d3bbc /usr.bin/whereis
parentaf43ddac0b5edf1f35d92451064f8a76b731ed24 (diff)
downloadFreeBSD-src-28378cc9b0121596ba0047e10887e682677ce47d.zip
FreeBSD-src-28378cc9b0121596ba0047e10887e682677ce47d.tar.gz
Correctly handle empty path arguments, e.g., whereis -S -f biff.
Approved by: joerg, sheldonh (mentor)
Diffstat (limited to 'usr.bin/whereis')
-rw-r--r--usr.bin/whereis/whereis.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/usr.bin/whereis/whereis.c b/usr.bin/whereis/whereis.c
index e78e089..58ca04a 100644
--- a/usr.bin/whereis/whereis.c
+++ b/usr.bin/whereis/whereis.c
@@ -114,20 +114,16 @@ scanopts(int argc, char **argv)
dirlist = &sourcedirs;
dolist:
i = 0;
+ *dirlist = realloc(*dirlist, (i + 1) * sizeof(char *));
+ (*dirlist)[i] = NULL;
while (optind < argc &&
strcmp(argv[optind], "-f") != 0 &&
strcmp(argv[optind], "-B") != 0 &&
strcmp(argv[optind], "-M") != 0 &&
strcmp(argv[optind], "-S") != 0) {
- *dirlist = realloc(*dirlist,
- (i + 2) * sizeof(char *));
- if (*dirlist == NULL)
- abort();
- (*dirlist)[i] = argv[optind];
- i++;
+ decolonify(argv[optind], dirlist, &i);
optind++;
}
- (*dirlist)[i] = NULL;
break;
case 'b':
OpenPOWER on IntegriCloud