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 |
4 files changed, 8 insertions, 6 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; |