mkdir(1): Don't reference memory beyond the end of the path
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 31 Aug 2011 06:24:05 +0000 (14:24 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 31 Aug 2011 06:24:05 +0000 (14:24 +0800)
bin/mkdir/mkdir.c

index 3b235f0..0584d4d 100644 (file)
@@ -148,7 +148,7 @@ build(char *path, mode_t omode)
                else if (p[0] != '/')
                        continue;
                *p = '\0';
-               if (p[1] == '\0')
+               if (!last && p[1] == '\0')
                        last = 1;
                if (first) {
                        /*