inetd: fix order of array index check and array access
[oweals/busybox.git] / coreutils / mkdir.c
index b33b6bba3b5c8cf34f3edad416f9151bae598343..864edfb0a1873f733d0605985aaaa0c59bf72387 100644 (file)
@@ -47,6 +47,9 @@ static const char mkdir_longopts[] ALIGN1 =
        "parents\0" No_argument       "p"
 #if ENABLE_SELINUX
        "context\0" Required_argument "Z"
+#endif
+#if ENABLE_FEATURE_VERBOSE
+       "verbose\0" No_argument       "v"
 #endif
        ;
 #endif
@@ -66,7 +69,7 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv)
 #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
        applet_long_options = mkdir_longopts;
 #endif
-       opt = getopt32(argv, "m:p" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
+       opt = getopt32(argv, "m:pv" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
        if (opt & 1) {
                mode_t mmode = 0777;
                if (!bb_parse_mode(smode, &mmode)) {
@@ -76,8 +79,10 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv)
        }
        if (opt & 2)
                flags |= FILEUTILS_RECUR;
+       if ((opt & 4) && FILEUTILS_VERBOSE)
+               flags |= FILEUTILS_VERBOSE;
 #if ENABLE_SELINUX
-       if (opt & 4) {
+       if (opt & 8) {
                selinux_or_die();
                setfscreatecon_or_die(scontext);
        }