diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/chmod.c | 4 | ||||
-rw-r--r-- | coreutils/install.c | 2 | ||||
-rw-r--r-- | coreutils/libcoreutils/getopt_mk_fifo_nod.c | 4 | ||||
-rw-r--r-- | coreutils/mkdir.c | 4 | ||||
-rw-r--r-- | coreutils/sort.c | 12 | ||||
-rw-r--r-- | coreutils/uniq.c | 2 | ||||
-rw-r--r-- | coreutils/uudecode.c | 13 | ||||
-rw-r--r-- | coreutils/who.c | 2 |
8 files changed, 30 insertions, 13 deletions
diff --git a/coreutils/chmod.c b/coreutils/chmod.c index 5ee45b942..a21c6d501 100644 --- a/coreutils/chmod.c +++ b/coreutils/chmod.c | |||
@@ -69,9 +69,9 @@ static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void | |||
69 | if (S_ISLNK(statbuf->st_mode)) | 69 | if (S_ISLNK(statbuf->st_mode)) |
70 | return TRUE; | 70 | return TRUE; |
71 | } | 71 | } |
72 | newmode = statbuf->st_mode; | ||
73 | 72 | ||
74 | if (!bb_parse_mode((char *)param, &newmode)) | 73 | newmode = bb_parse_mode((char *)param, statbuf->st_mode); |
74 | if (newmode == (mode_t)-1) | ||
75 | bb_error_msg_and_die("invalid mode '%s'", (char *)param); | 75 | bb_error_msg_and_die("invalid mode '%s'", (char *)param); |
76 | 76 | ||
77 | if (chmod(fileName, newmode) == 0) { | 77 | if (chmod(fileName, newmode) == 0) { |
diff --git a/coreutils/install.c b/coreutils/install.c index 73f9c70d5..8aa51cc34 100644 --- a/coreutils/install.c +++ b/coreutils/install.c | |||
@@ -159,7 +159,7 @@ int install_main(int argc, char **argv) | |||
159 | } | 159 | } |
160 | mode = 0755; /* GNU coreutils 6.10 compat */ | 160 | mode = 0755; /* GNU coreutils 6.10 compat */ |
161 | if (opts & OPT_MODE) | 161 | if (opts & OPT_MODE) |
162 | bb_parse_mode(mode_str, &mode); | 162 | mode = bb_parse_mode(mode_str, mode); |
163 | uid = (opts & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid(); | 163 | uid = (opts & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid(); |
164 | gid = (opts & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid(); | 164 | gid = (opts & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid(); |
165 | 165 | ||
diff --git a/coreutils/libcoreutils/getopt_mk_fifo_nod.c b/coreutils/libcoreutils/getopt_mk_fifo_nod.c index 222717149..47375ff91 100644 --- a/coreutils/libcoreutils/getopt_mk_fifo_nod.c +++ b/coreutils/libcoreutils/getopt_mk_fifo_nod.c | |||
@@ -33,7 +33,9 @@ mode_t FAST_FUNC getopt_mk_fifo_nod(char **argv) | |||
33 | int opt; | 33 | int opt; |
34 | opt = getopt32(argv, "m:" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext)); | 34 | opt = getopt32(argv, "m:" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext)); |
35 | if (opt & 1) { | 35 | if (opt & 1) { |
36 | if (bb_parse_mode(smode, &mode)) | 36 | mode = bb_parse_mode(smode, mode); |
37 | if (mode != (mode_t)-1) /* if mode is valid */ | ||
38 | /* make future mknod/mkfifo set mode bits exactly */ | ||
37 | umask(0); | 39 | umask(0); |
38 | } | 40 | } |
39 | 41 | ||
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index 864edfb0a..6f7b004dd 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c | |||
@@ -71,8 +71,8 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv) | |||
71 | #endif | 71 | #endif |
72 | opt = getopt32(argv, "m:pv" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext)); | 72 | opt = getopt32(argv, "m:pv" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext)); |
73 | if (opt & 1) { | 73 | if (opt & 1) { |
74 | mode_t mmode = 0777; | 74 | mode_t mmode = bb_parse_mode(smode, 0777); |
75 | if (!bb_parse_mode(smode, &mmode)) { | 75 | if (mmode == (mode_t)-1) { |
76 | bb_error_msg_and_die("invalid mode '%s'", smode); | 76 | bb_error_msg_and_die("invalid mode '%s'", smode); |
77 | } | 77 | } |
78 | mode = mmode; | 78 | mode = mmode; |
diff --git a/coreutils/sort.c b/coreutils/sort.c index 1cb4c3e3f..36f02543b 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
@@ -25,14 +25,14 @@ | |||
25 | //usage: "\n -f Ignore case" | 25 | //usage: "\n -f Ignore case" |
26 | //usage: "\n -g General numerical sort" | 26 | //usage: "\n -g General numerical sort" |
27 | //usage: "\n -i Ignore unprintable characters" | 27 | //usage: "\n -i Ignore unprintable characters" |
28 | //usage: "\n -k Sort key" | ||
29 | //usage: "\n -M Sort month" | 28 | //usage: "\n -M Sort month" |
30 | //usage: ) | 29 | //usage: ) |
30 | //-h, --human-numeric-sort: compare human readable numbers (e.g., 2K 1G) | ||
31 | //usage: "\n -n Sort numbers" | 31 | //usage: "\n -n Sort numbers" |
32 | //usage: IF_FEATURE_SORT_BIG( | 32 | //usage: IF_FEATURE_SORT_BIG( |
33 | //usage: "\n -o Output to file" | 33 | //usage: "\n -o Output to file" |
34 | //usage: "\n -k Sort by key" | 34 | //usage: "\n -t CHAR Field separator" |
35 | //usage: "\n -t CHAR Key separator" | 35 | //usage: "\n -k N[,M] Sort by Nth field" |
36 | //usage: ) | 36 | //usage: ) |
37 | //usage: "\n -r Reverse sort order" | 37 | //usage: "\n -r Reverse sort order" |
38 | //usage: IF_FEATURE_SORT_BIG( | 38 | //usage: IF_FEATURE_SORT_BIG( |
@@ -143,6 +143,9 @@ static char *get_key(char *str, struct sort_key *key, int flags) | |||
143 | } | 143 | } |
144 | } | 144 | } |
145 | } | 145 | } |
146 | /* Remove last delim: "abc:def:" => "abc:def" */ | ||
147 | if (key_separator && j && end != 0) | ||
148 | end--; | ||
146 | } | 149 | } |
147 | if (!j) start = end; | 150 | if (!j) start = end; |
148 | } | 151 | } |
@@ -163,7 +166,8 @@ static char *get_key(char *str, struct sort_key *key, int flags) | |||
163 | if (start > len) start = len; | 166 | if (start > len) start = len; |
164 | } | 167 | } |
165 | /* Make the copy */ | 168 | /* Make the copy */ |
166 | if (end < start) end = start; | 169 | if (end < start) |
170 | end = start; | ||
167 | str = xstrndup(str+start, end-start); | 171 | str = xstrndup(str+start, end-start); |
168 | /* Handle -d */ | 172 | /* Handle -d */ |
169 | if (flags & FLAG_d) { | 173 | if (flags & FLAG_d) { |
diff --git a/coreutils/uniq.c b/coreutils/uniq.c index 9208d34ec..e0133998a 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c | |||
@@ -112,7 +112,7 @@ int uniq_main(int argc UNUSED_PARAM, char **argv) | |||
112 | /* %7lu matches GNU coreutils 6.9 */ | 112 | /* %7lu matches GNU coreutils 6.9 */ |
113 | printf("%7lu ", dups + 1); | 113 | printf("%7lu ", dups + 1); |
114 | } | 114 | } |
115 | printf("%s\n", old_line); | 115 | puts(old_line); |
116 | } | 116 | } |
117 | free(old_line); | 117 | free(old_line); |
118 | } | 118 | } |
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 7aa5c67f2..37b254d30 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -29,9 +29,19 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U | |||
29 | { | 29 | { |
30 | char *line; | 30 | char *line; |
31 | 31 | ||
32 | while ((line = xmalloc_fgetline(src_stream)) != NULL) { | 32 | for (;;) { |
33 | int encoded_len, str_len; | 33 | int encoded_len, str_len; |
34 | char *line_ptr, *dst; | 34 | char *line_ptr, *dst; |
35 | size_t line_len; | ||
36 | |||
37 | line_len = 64 * 1024; | ||
38 | line = xmalloc_fgets_str_len(src_stream, "\n", &line_len); | ||
39 | if (!line) | ||
40 | break; | ||
41 | /* Handle both Unix and MSDOS text, and stray trailing spaces */ | ||
42 | str_len = line_len; | ||
43 | while (--str_len >= 0 && isspace(line[str_len])) | ||
44 | line[str_len] = '\0'; | ||
35 | 45 | ||
36 | if (strcmp(line, "end") == 0) { | 46 | if (strcmp(line, "end") == 0) { |
37 | return; /* the only non-error exit */ | 47 | return; /* the only non-error exit */ |
@@ -128,6 +138,7 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv) | |||
128 | if (!outname) | 138 | if (!outname) |
129 | break; | 139 | break; |
130 | outname++; | 140 | outname++; |
141 | trim(outname); /* remove trailing space (and '\r' for DOS text) */ | ||
131 | if (!outname[0]) | 142 | if (!outname[0]) |
132 | break; | 143 | break; |
133 | } | 144 | } |
diff --git a/coreutils/who.c b/coreutils/who.c index 8337212c9..f694d0c60 100644 --- a/coreutils/who.c +++ b/coreutils/who.c | |||
@@ -81,7 +81,7 @@ int who_main(int argc UNUSED_PARAM, char **argv) | |||
81 | opt_complementary = "=0"; | 81 | opt_complementary = "=0"; |
82 | opt = getopt32(argv, do_users ? "" : "aH"); | 82 | opt = getopt32(argv, do_users ? "" : "aH"); |
83 | if (opt & 2) // -H | 83 | if (opt & 2) // -H |
84 | printf("USER\t\tTTY\t\tIDLE\tTIME\t\t HOST\n"); | 84 | puts("USER\t\tTTY\t\tIDLE\tTIME\t\t HOST"); |
85 | 85 | ||
86 | setutxent(); | 86 | setutxent(); |
87 | while ((ut = getutxent()) != NULL) { | 87 | while ((ut = getutxent()) != NULL) { |