* Fix confusing error messages due to corrupted string after make_dir() failure. (Thanks Wolfram Gloger)
This commit is contained in:
parent
4d6b956bda
commit
a875a67996
15
utils.c
15
utils.c
@ -191,7 +191,7 @@ make_dir(char * path, mode_t mode)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
c = 0;
|
c = '\0';
|
||||||
|
|
||||||
/* Bypass leading non-'/'s and then subsequent '/'s. */
|
/* Bypass leading non-'/'s and then subsequent '/'s. */
|
||||||
while (*s) {
|
while (*s) {
|
||||||
@ -200,7 +200,7 @@ make_dir(char * path, mode_t mode)
|
|||||||
++s;
|
++s;
|
||||||
} while (*s == '/');
|
} while (*s == '/');
|
||||||
c = *s; /* Save the current char */
|
c = *s; /* Save the current char */
|
||||||
*s = 0; /* and replace it with nul. */
|
*s = '\0'; /* and replace it with nul. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++s;
|
++s;
|
||||||
@ -209,9 +209,11 @@ make_dir(char * path, mode_t mode)
|
|||||||
if (mkdir(path, mode) < 0) {
|
if (mkdir(path, mode) < 0) {
|
||||||
/* If we failed for any other reason than the directory
|
/* If we failed for any other reason than the directory
|
||||||
* already exists, output a diagnostic and return -1.*/
|
* already exists, output a diagnostic and return -1.*/
|
||||||
if (errno != EEXIST
|
if (errno != EEXIST || (stat(path, &st) < 0 || !S_ISDIR(st.st_mode))) {
|
||||||
|| (stat(path, &st) < 0 || !S_ISDIR(st.st_mode))) {
|
DPRINTF(E_WARN, L_GENERAL, "make_dir: cannot create directory '%s'\n", path);
|
||||||
break;
|
if (c)
|
||||||
|
*s = c;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!c)
|
if (!c)
|
||||||
@ -221,9 +223,6 @@ make_dir(char * path, mode_t mode)
|
|||||||
*s = c;
|
*s = c;
|
||||||
|
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
DPRINTF(E_WARN, L_GENERAL, "make_dir: cannot create directory '%s'\n", path);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user