]> arthur.barton.de Git - netatalk.git/commitdiff
Fix ressource fork name conversion
authorRalph Boehme <sloowfranklin@gmail.com>
Fri, 18 Oct 2013 15:07:41 +0000 (17:07 +0200)
committerRalph Boehme <sloowfranklin@gmail.com>
Fri, 18 Oct 2013 15:07:41 +0000 (17:07 +0200)
Function was using ad_path() which returns a pointer to a static
string twice in the rename() functions.

Fixes bug #534.

libatalk/adouble/ad_conv.c

index b1785c0163f30cf73eb3dde56794e4b6150e7d0e..2a75ec62b576bb25a6ade1a269cee52db5c98bba 100644 (file)
@@ -210,6 +210,7 @@ static int ad_conv_dehex(const char *path, const struct stat *sp, const struct v
     static bstring str2f = NULL;
     static bstring strdot = NULL;
     static bstring strcolon = NULL;
+    char *newadpath = NULL;
 
     if (str2e == NULL) {
         str2e = bfromcstr(":2e");
@@ -231,8 +232,13 @@ static int ad_conv_dehex(const char *path, const struct stat *sp, const struct v
     EC_ZERO( bfindreplace(newpath, str2f, strcolon, 0) );
     
     become_root();
-    if (adflags != ADFLAGS_DIR)
-        rename(vol->ad_path(path, 0), vol->ad_path(bdata(newpath), 0));
+    if (adflags != ADFLAGS_DIR) {
+        if ((newadpath = strdup(vol->ad_path(bdata(newpath), 0))) == NULL) {
+            unbecome_root();
+            EC_FAIL;
+        }
+        rename(vol->ad_path(path, 0), newadpath);
+    }
     rename(path, bdata(newpath));
     unbecome_root();
 
@@ -242,6 +248,8 @@ static int ad_conv_dehex(const char *path, const struct stat *sp, const struct v
 EC_CLEANUP:
     if (newpath)
         bdestroy(newpath);
+    if (newadpath)
+        free(newadpath);
     EC_EXIT;
 }