Likely fix for bug #33140

This commit is contained in:
Ilia Alshanetsky 2005-06-24 02:04:19 +00:00
parent f3f97394b2
commit 87d6f497f7

View File

@ -1079,18 +1079,24 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod
char *e, *buf;
struct stat sb;
int dir_len = strlen(dir);
int offset = 0;
buf = estrndup(dir, dir_len);
e = buf + dir_len;
if ((p = memchr(buf, DEFAULT_SLASH, dir_len))) {
offset = p - buf + 1;
}
/* find a top level directory we need to create */
while ((p = strrchr(buf, DEFAULT_SLASH))) {
while ((p = strrchr(buf + offset, DEFAULT_SLASH))) {
*p = '\0';
if (VCWD_STAT(buf, &sb) == 0) {
*p = DEFAULT_SLASH;
break;
}
}
if (p == buf) {
ret = php_mkdir(dir, mode TSRMLS_CC);
} else if (!(ret = php_mkdir(buf, mode TSRMLS_CC))) {