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 /coreutils | |
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
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/ln.c | 37 | ||||
-rw-r--r-- | coreutils/rm.c | 37 |
2 files changed, 42 insertions, 32 deletions
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 | ||