Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/azatoth/minidlna.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Maggard <jmaggard@users.sourceforce.net>2011-07-18 22:13:25 +0400
committerJustin Maggard <jmaggard@users.sourceforce.net>2011-07-18 22:13:25 +0400
commit0a1331f3c28e5ac3ea80b32cda60e88f13b76160 (patch)
treeff1e5ee2cccbb413c9e544ff2051646124aa1633
parent4b58a9cae15492377193f71941026e3cb241a4fb (diff)
* Fix confusing error messages due to corrupted string after make_dir() failure. (Thanks Wolfram Gloger)
-rw-r--r--utils.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/utils.c b/utils.c
index 136fbda..22fe37a 100644
--- a/utils.c
+++ b/utils.c
@@ -191,7 +191,7 @@ make_dir(char * path, mode_t mode)
struct stat st;
do {
- c = 0;
+ c = '\0';
/* Bypass leading non-'/'s and then subsequent '/'s. */
while (*s) {
@@ -200,7 +200,7 @@ make_dir(char * path, mode_t mode)
++s;
} while (*s == '/');
c = *s; /* Save the current char */
- *s = 0; /* and replace it with nul. */
+ *s = '\0'; /* and replace it with nul. */
break;
}
++s;
@@ -209,9 +209,11 @@ make_dir(char * path, mode_t mode)
if (mkdir(path, mode) < 0) {
/* If we failed for any other reason than the directory
* already exists, output a diagnostic and return -1.*/
- if (errno != EEXIST
- || (stat(path, &st) < 0 || !S_ISDIR(st.st_mode))) {
- break;
+ if (errno != EEXIST || (stat(path, &st) < 0 || !S_ISDIR(st.st_mode))) {
+ DPRINTF(E_WARN, L_GENERAL, "make_dir: cannot create directory '%s'\n", path);
+ if (c)
+ *s = c;
+ return -1;
}
}
if (!c)
@@ -221,9 +223,6 @@ make_dir(char * path, mode_t mode)
*s = c;
} while (1);
-
- DPRINTF(E_WARN, L_GENERAL, "make_dir: cannot create directory '%s'\n", path);
- return -1;
}
int