diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-06-06 16:15:23 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-06-06 16:15:23 +0000 |
commit | 815e90447064e287ad181c1231636e7f1b44f76c (patch) | |
tree | 0955917be0c7adc926b7298bf450fedc67e447e6 | |
parent | c389d9118152e45303173c221a33a8083e769884 (diff) | |
download | busybox-w32-815e90447064e287ad181c1231636e7f1b44f76c.tar.gz busybox-w32-815e90447064e287ad181c1231636e7f1b44f76c.tar.bz2 busybox-w32-815e90447064e287ad181c1231636e7f1b44f76c.zip |
Fixed a bunch of stuff:
* Fixed segfault caused by "touch -c"
* Fixed segfault caused by "rm -f"
* Fixed segfault caused by "ln -s -s" and similar abuses.
* Fixed segfault caused by "cp -a -a" and similar abuses.
* Implemented "rm -- <foo>"
updated docs accordingly.
-Erik
-rw-r--r-- | Changelog | 5 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | coreutils/ln.c | 37 | ||||
-rw-r--r-- | coreutils/rm.c | 37 | ||||
-rw-r--r-- | cp_mv.c | 51 | ||||
-rw-r--r-- | docs/busybox.pod | 5 | ||||
-rw-r--r-- | ln.c | 37 | ||||
-rw-r--r-- | mkfs_minix.c | 2 | ||||
-rw-r--r-- | rm.c | 37 | ||||
-rw-r--r-- | util-linux/mkfs_minix.c | 2 |
11 files changed, 123 insertions, 98 deletions
@@ -50,6 +50,11 @@ | |||
50 | * Fixed all fatalError() calls lacking a "\n", thanks to Pavel Roskin. | 50 | * Fixed all fatalError() calls lacking a "\n", thanks to Pavel Roskin. |
51 | * Fixed a segfault in yes when no args were given -- Pavel Roskin. | 51 | * Fixed a segfault in yes when no args were given -- Pavel Roskin. |
52 | * Simplified freeramdisk and added argument checking -- Pavel Roskin. | 52 | * Simplified freeramdisk and added argument checking -- Pavel Roskin. |
53 | * Fixed segfault caused by "touch -c" | ||
54 | * Fixed segfault caused by "rm -f" | ||
55 | * Fixed segfault caused by "ln -s -s" and similar abuses. | ||
56 | * Fixed segfault caused by "cp -a -a" and similar abuses. | ||
57 | * Implemented "rm -- <foo>" | ||
53 | * "which" rewritten to use stat(). Fixes to improve its compatability | 58 | * "which" rewritten to use stat(). Fixes to improve its compatability |
54 | with traditional implementations -- Pavel Roskin. | 59 | with traditional implementations -- Pavel Roskin. |
55 | * More doc updates | 60 | * More doc updates |
@@ -26,7 +26,7 @@ export VERSION | |||
26 | # Set the following to `true' to make a debuggable build. | 26 | # Set the following to `true' to make a debuggable build. |
27 | # Leave this set to `false' for production use. | 27 | # Leave this set to `false' for production use. |
28 | # eg: `make DODEBUG=true tests' | 28 | # eg: `make DODEBUG=true tests' |
29 | DODEBUG = false | 29 | DODEBUG = true |
30 | 30 | ||
31 | # If you want a static binary, turn this on. | 31 | # If you want a static binary, turn this on. |
32 | DOSTATIC = false | 32 | DOSTATIC = false |
@@ -26,12 +26,6 @@ Bugs that need fixing before the 0.44 release goes out the door: | |||
26 | chmod -R | 26 | chmod -R |
27 | chown -R | 27 | chown -R |
28 | chgrp -R | 28 | chgrp -R |
29 | cp -a -a | ||
30 | ln -s -s | ||
31 | rm -f | ||
32 | rm -f - | ||
33 | rm -- - | ||
34 | touch -c | ||
35 | - I believe that swaponoff may also be also broken (check it). | 29 | - I believe that swaponoff may also be also broken (check it). |
36 | - It used to be that BusyBox tar would happily overwrite existing files on | 30 | - It used to be that BusyBox tar would happily overwrite existing files on |
37 | an extraction. However, as of 0.42, BusyBox tar simply dies as soon as an | 31 | an extraction. However, as of 0.42, BusyBox tar simply dies as soon as an |
diff --git a/coreutils/ln.c b/coreutils/ln.c index 29ff93863..d4fa47306 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c | |||
@@ -59,25 +59,30 @@ extern int ln_main(int argc, char **argv) | |||
59 | argv++; | 59 | argv++; |
60 | 60 | ||
61 | /* Parse any options */ | 61 | /* Parse any options */ |
62 | while (**argv == '-') { | 62 | while (--argc >= 0 && *argv && **argv) { |
63 | while (*++(*argv)) | 63 | while (**argv == '-') { |
64 | switch (**argv) { | 64 | while (*++(*argv)) |
65 | case 's': | 65 | switch (**argv) { |
66 | symlinkFlag = TRUE; | 66 | case 's': |
67 | break; | 67 | symlinkFlag = TRUE; |
68 | case 'f': | 68 | break; |
69 | removeoldFlag = TRUE; | 69 | case 'f': |
70 | break; | 70 | removeoldFlag = TRUE; |
71 | case 'n': | 71 | break; |
72 | followLinks = FALSE; | 72 | case 'n': |
73 | break; | 73 | followLinks = FALSE; |
74 | default: | 74 | break; |
75 | usage(ln_usage); | 75 | default: |
76 | } | 76 | usage(ln_usage); |
77 | argc--; | 77 | } |
78 | } | ||
78 | argv++; | 79 | argv++; |
79 | } | 80 | } |
80 | 81 | ||
82 | if (argc < 1) { | ||
83 | fatalError("ln: missing file argument\n"); | ||
84 | } | ||
85 | |||
81 | linkName = argv[argc - 1]; | 86 | linkName = argv[argc - 1]; |
82 | 87 | ||
83 | if (strlen(linkName) > BUFSIZ) { | 88 | if (strlen(linkName) > BUFSIZ) { |
diff --git a/coreutils/rm.c b/coreutils/rm.c index c62d68aba..5901c5da9 100644 --- a/coreutils/rm.c +++ b/coreutils/rm.c | |||
@@ -31,7 +31,8 @@ | |||
31 | 31 | ||
32 | static const char *rm_usage = "rm [OPTION]... FILE...\n" | 32 | static const char *rm_usage = "rm [OPTION]... FILE...\n" |
33 | #ifndef BB_FEATURE_TRIVIAL_HELP | 33 | #ifndef BB_FEATURE_TRIVIAL_HELP |
34 | "\nRemove (unlink) the FILE(s).\n\n" | 34 | "\nRemove (unlink) the FILE(s). You may use '--' to\n" |
35 | "indicate that all following arguments are non-options.\n\n" | ||
35 | "Options:\n" | 36 | "Options:\n" |
36 | "\t-f\t\tremove existing destinations, never prompt\n" | 37 | "\t-f\t\tremove existing destinations, never prompt\n" |
37 | "\t-r or -R\tremove the contents of directories recursively\n" | 38 | "\t-r or -R\tremove the contents of directories recursively\n" |
@@ -64,29 +65,33 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk) | |||
64 | 65 | ||
65 | extern int rm_main(int argc, char **argv) | 66 | extern int rm_main(int argc, char **argv) |
66 | { | 67 | { |
68 | int stopIt=FALSE; | ||
67 | struct stat statbuf; | 69 | struct stat statbuf; |
68 | 70 | ||
69 | if (argc < 2) { | 71 | if (argc < 2) { |
70 | usage(rm_usage); | 72 | usage(rm_usage); |
71 | } | 73 | } |
72 | argc--; | ||
73 | argv++; | 74 | argv++; |
74 | 75 | ||
75 | /* Parse any options */ | 76 | /* Parse any options */ |
76 | while (**argv == '-') { | 77 | while (--argc >= 0 && *argv && **argv && stopIt==FALSE) { |
77 | while (*++(*argv)) | 78 | while (**argv == '-') { |
78 | switch (**argv) { | 79 | while (*++(*argv)) |
79 | case 'R': | 80 | switch (**argv) { |
80 | case 'r': | 81 | case 'R': |
81 | recursiveFlag = TRUE; | 82 | case 'r': |
82 | break; | 83 | recursiveFlag = TRUE; |
83 | case 'f': | 84 | break; |
84 | forceFlag = TRUE; | 85 | case 'f': |
85 | break; | 86 | forceFlag = TRUE; |
86 | default: | 87 | break; |
87 | usage(rm_usage); | 88 | case '-': |
88 | } | 89 | stopIt = TRUE; |
89 | argc--; | 90 | break; |
91 | default: | ||
92 | usage(rm_usage); | ||
93 | } | ||
94 | } | ||
90 | argv++; | 95 | argv++; |
91 | } | 96 | } |
92 | 97 | ||
@@ -203,37 +203,42 @@ extern int cp_mv_main(int argc, char **argv) | |||
203 | if (dz_i == is_cp) { | 203 | if (dz_i == is_cp) { |
204 | recursiveFlag = preserveFlag = forceFlag = FALSE; | 204 | recursiveFlag = preserveFlag = forceFlag = FALSE; |
205 | followLinks = TRUE; | 205 | followLinks = TRUE; |
206 | while (**argv == '-') { | 206 | while (--argc >= 0 && *argv && **argv) { |
207 | while (*++(*argv)) { | 207 | while (**argv == '-') { |
208 | switch (**argv) { | 208 | while (*++(*argv)) { |
209 | case 'a': | 209 | switch (**argv) { |
210 | followLinks = FALSE; | 210 | case 'a': |
211 | preserveFlag = TRUE; | 211 | followLinks = FALSE; |
212 | recursiveFlag = TRUE; | 212 | preserveFlag = TRUE; |
213 | break; | 213 | recursiveFlag = TRUE; |
214 | case 'd': | 214 | break; |
215 | followLinks = FALSE; | 215 | case 'd': |
216 | break; | 216 | followLinks = FALSE; |
217 | case 'p': | 217 | break; |
218 | preserveFlag = TRUE; | 218 | case 'p': |
219 | break; | 219 | preserveFlag = TRUE; |
220 | case 'R': | 220 | break; |
221 | recursiveFlag = TRUE; | 221 | case 'R': |
222 | break; | 222 | recursiveFlag = TRUE; |
223 | case 'f': | 223 | break; |
224 | forceFlag = TRUE; | 224 | case 'f': |
225 | break; | 225 | forceFlag = TRUE; |
226 | default: | 226 | break; |
227 | usage(cp_mv_usage[is_cp]); | 227 | default: |
228 | usage(cp_mv_usage[is_cp]); | ||
229 | } | ||
228 | } | 230 | } |
229 | } | 231 | } |
230 | argc--; | ||
231 | argv++; | 232 | argv++; |
232 | } | 233 | } |
234 | if (argc < 1) { | ||
235 | fatalError("cp: missing file argument\n"); | ||
236 | } | ||
233 | } else { /* (dz_i == is_mv) */ | 237 | } else { /* (dz_i == is_mv) */ |
234 | recursiveFlag = preserveFlag = TRUE; | 238 | recursiveFlag = preserveFlag = TRUE; |
235 | followLinks = FALSE; | 239 | followLinks = FALSE; |
236 | } | 240 | } |
241 | |||
237 | 242 | ||
238 | if (strlen(argv[argc - 1]) > BUFSIZ) { | 243 | if (strlen(argv[argc - 1]) > BUFSIZ) { |
239 | fprintf(stderr, name_too_long, "cp"); | 244 | fprintf(stderr, name_too_long, "cp"); |
diff --git a/docs/busybox.pod b/docs/busybox.pod index 272885164..7b76e7e79 100644 --- a/docs/busybox.pod +++ b/docs/busybox.pod | |||
@@ -1327,7 +1327,8 @@ Instructs the kernel to reboot the system. | |||
1327 | 1327 | ||
1328 | Usage: rm [OPTION]... FILE... | 1328 | Usage: rm [OPTION]... FILE... |
1329 | 1329 | ||
1330 | Remove (unlink) the FILE(s). | 1330 | Remove (unlink) the FILE(s). You may use '--' to |
1331 | indicate that all following arguments are non-options. | ||
1331 | 1332 | ||
1332 | Options: | 1333 | Options: |
1333 | 1334 | ||
@@ -1946,4 +1947,4 @@ Enrique Zanardi <ezanardi@ull.es> | |||
1946 | 1947 | ||
1947 | =cut | 1948 | =cut |
1948 | 1949 | ||
1949 | # $Id: busybox.pod,v 1.34 2000/06/05 17:23:06 andersen Exp $ | 1950 | # $Id: busybox.pod,v 1.35 2000/06/06 16:15:23 andersen Exp $ |
@@ -59,25 +59,30 @@ extern int ln_main(int argc, char **argv) | |||
59 | argv++; | 59 | argv++; |
60 | 60 | ||
61 | /* Parse any options */ | 61 | /* Parse any options */ |
62 | while (**argv == '-') { | 62 | while (--argc >= 0 && *argv && **argv) { |
63 | while (*++(*argv)) | 63 | while (**argv == '-') { |
64 | switch (**argv) { | 64 | while (*++(*argv)) |
65 | case 's': | 65 | switch (**argv) { |
66 | symlinkFlag = TRUE; | 66 | case 's': |
67 | break; | 67 | symlinkFlag = TRUE; |
68 | case 'f': | 68 | break; |
69 | removeoldFlag = TRUE; | 69 | case 'f': |
70 | break; | 70 | removeoldFlag = TRUE; |
71 | case 'n': | 71 | break; |
72 | followLinks = FALSE; | 72 | case 'n': |
73 | break; | 73 | followLinks = FALSE; |
74 | default: | 74 | break; |
75 | usage(ln_usage); | 75 | default: |
76 | } | 76 | usage(ln_usage); |
77 | argc--; | 77 | } |
78 | } | ||
78 | argv++; | 79 | argv++; |
79 | } | 80 | } |
80 | 81 | ||
82 | if (argc < 1) { | ||
83 | fatalError("ln: missing file argument\n"); | ||
84 | } | ||
85 | |||
81 | linkName = argv[argc - 1]; | 86 | linkName = argv[argc - 1]; |
82 | 87 | ||
83 | if (strlen(linkName) > BUFSIZ) { | 88 | if (strlen(linkName) > BUFSIZ) { |
diff --git a/mkfs_minix.c b/mkfs_minix.c index c6f057a07..ef37c385d 100644 --- a/mkfs_minix.c +++ b/mkfs_minix.c | |||
@@ -188,7 +188,7 @@ static volatile void show_usage() | |||
188 | fprintf(stderr, | 188 | fprintf(stderr, |
189 | "\t-n [14|30]\tSpecify the maximum length of filenames\n"); | 189 | "\t-n [14|30]\tSpecify the maximum length of filenames\n"); |
190 | fprintf(stderr, | 190 | fprintf(stderr, |
191 | "\t-i\t\tSpecify the number of inodes for the filesystem\n"); | 191 | "\t-i INODES\tSpecify the number of inodes for the filesystem\n"); |
192 | fprintf(stderr, | 192 | fprintf(stderr, |
193 | "\t-l FILENAME\tRead the bad blocks list from FILENAME\n"); | 193 | "\t-l FILENAME\tRead the bad blocks list from FILENAME\n"); |
194 | fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n"); | 194 | fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n"); |
@@ -31,7 +31,8 @@ | |||
31 | 31 | ||
32 | static const char *rm_usage = "rm [OPTION]... FILE...\n" | 32 | static const char *rm_usage = "rm [OPTION]... FILE...\n" |
33 | #ifndef BB_FEATURE_TRIVIAL_HELP | 33 | #ifndef BB_FEATURE_TRIVIAL_HELP |
34 | "\nRemove (unlink) the FILE(s).\n\n" | 34 | "\nRemove (unlink) the FILE(s). You may use '--' to\n" |
35 | "indicate that all following arguments are non-options.\n\n" | ||
35 | "Options:\n" | 36 | "Options:\n" |
36 | "\t-f\t\tremove existing destinations, never prompt\n" | 37 | "\t-f\t\tremove existing destinations, never prompt\n" |
37 | "\t-r or -R\tremove the contents of directories recursively\n" | 38 | "\t-r or -R\tremove the contents of directories recursively\n" |
@@ -64,29 +65,33 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk) | |||
64 | 65 | ||
65 | extern int rm_main(int argc, char **argv) | 66 | extern int rm_main(int argc, char **argv) |
66 | { | 67 | { |
68 | int stopIt=FALSE; | ||
67 | struct stat statbuf; | 69 | struct stat statbuf; |
68 | 70 | ||
69 | if (argc < 2) { | 71 | if (argc < 2) { |
70 | usage(rm_usage); | 72 | usage(rm_usage); |
71 | } | 73 | } |
72 | argc--; | ||
73 | argv++; | 74 | argv++; |
74 | 75 | ||
75 | /* Parse any options */ | 76 | /* Parse any options */ |
76 | while (**argv == '-') { | 77 | while (--argc >= 0 && *argv && **argv && stopIt==FALSE) { |
77 | while (*++(*argv)) | 78 | while (**argv == '-') { |
78 | switch (**argv) { | 79 | while (*++(*argv)) |
79 | case 'R': | 80 | switch (**argv) { |
80 | case 'r': | 81 | case 'R': |
81 | recursiveFlag = TRUE; | 82 | case 'r': |
82 | break; | 83 | recursiveFlag = TRUE; |
83 | case 'f': | 84 | break; |
84 | forceFlag = TRUE; | 85 | case 'f': |
85 | break; | 86 | forceFlag = TRUE; |
86 | default: | 87 | break; |
87 | usage(rm_usage); | 88 | case '-': |
88 | } | 89 | stopIt = TRUE; |
89 | argc--; | 90 | break; |
91 | default: | ||
92 | usage(rm_usage); | ||
93 | } | ||
94 | } | ||
90 | argv++; | 95 | argv++; |
91 | } | 96 | } |
92 | 97 | ||
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index c6f057a07..ef37c385d 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c | |||
@@ -188,7 +188,7 @@ static volatile void show_usage() | |||
188 | fprintf(stderr, | 188 | fprintf(stderr, |
189 | "\t-n [14|30]\tSpecify the maximum length of filenames\n"); | 189 | "\t-n [14|30]\tSpecify the maximum length of filenames\n"); |
190 | fprintf(stderr, | 190 | fprintf(stderr, |
191 | "\t-i\t\tSpecify the number of inodes for the filesystem\n"); | 191 | "\t-i INODES\tSpecify the number of inodes for the filesystem\n"); |
192 | fprintf(stderr, | 192 | fprintf(stderr, |
193 | "\t-l FILENAME\tRead the bad blocks list from FILENAME\n"); | 193 | "\t-l FILENAME\tRead the bad blocks list from FILENAME\n"); |
194 | fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n"); | 194 | fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n"); |