diff options
author | Justin Maggard <jmaggard@users.sourceforce.net> | 2011-07-18 22:13:25 +0400 |
---|---|---|
committer | Justin Maggard <jmaggard@users.sourceforce.net> | 2011-07-18 22:13:25 +0400 |
commit | 0a1331f3c28e5ac3ea80b32cda60e88f13b76160 (patch) | |
tree | ff1e5ee2cccbb413c9e544ff2051646124aa1633 | |
parent | 4b58a9cae15492377193f71941026e3cb241a4fb (diff) |
* Fix confusing error messages due to corrupted string after make_dir() failure. (Thanks Wolfram Gloger)
-rw-r--r-- | utils.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -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 |