]> arthur.barton.de Git - netatalk.git/commitdiff
Fix a bug where Mac OS X ZIP archives can't be extracted on Netatalk shares
authorFrank Lahm <franklahm@googlemail.com>
Tue, 9 Oct 2012 16:23:57 +0000 (18:23 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Thu, 11 Oct 2012 12:19:54 +0000 (14:19 +0200)
Mac OS X ZIP archives may contain split AppleDouble forks named "._XXX".
The client needs to be able to fully access these files but we currently
prevent access to any valid AppleDouble file whose name starts with "._".
In order to distinguish our own ._ files from the one created by OS X,
we look at the filler bytes: luckily OS X stores a string "Mac OS X" there
which can be used to detect them.

libatalk/adouble/ad_flush.c
libatalk/adouble/ad_open.c

index a637b27f2ebeb108db55d5eeeb9674684e43beb2..91f8058b6f0b2620c790e1e5347036686702e263 100644 (file)
@@ -167,7 +167,7 @@ static int ad_rebuild_adouble_header_osx(struct adouble *ad, char *adbuf)
     memcpy(buf, &temp, sizeof( temp ));
     buf += sizeof( temp );
 
-    memset(buf, 0, sizeof(ad->ad_filler));
+    memcpy(buf, "Netatalk        ", 16);
     buf += sizeof( ad->ad_filler );
 
     nent = htons(ADEID_NUM_OSX);
index 3e06e93fb6cfe7e715ac0de66be0d58cf0ae72a7..045c33c3b8f2f7c3631724168d80d57c1edfd7e9 100644 (file)
@@ -521,10 +521,18 @@ int ad_valid_header_osx(const char *path)
     adosx.ad_version = ntohl(adosx.ad_version);
 
     if ((adosx.ad_magic != AD_MAGIC) || (adosx.ad_version != AD_VERSION2)) {
-        LOG(log_error, logtype_afpd, "ad_valid_header_osx: not an adouble:ox file");
+        LOG(log_warning, logtype_afpd, "ad_valid_header_osx: not an adouble:osx file");
         EC_FAIL;
     }
 
+    if (strncmp(buf + ADEDOFF_FILLER, "Mac OS X", strlen("Mac OS X")) == 0)
+        /*
+         * It's a split fork created by OS X, it's not our "own" ._ file
+         * and thus not a valid header in this context.
+         * We allow enumeration and access.
+         */
+        EC_FAIL;
+
 EC_CLEANUP:
     LOG(log_debug, logtype_afpd, "ad_valid_header_osx(\"%s\"): END: %d", fullpathname(path), ret);
     if (fd != -1)