]> arthur.barton.de Git - netatalk.git/commitdiff
Unarchiving certain ZIP archives fails, bug #569
authorRalph Boehme <rb@sernet.de>
Tue, 17 Jun 2014 15:02:20 +0000 (17:02 +0200)
committerRalph Boehme <rb@sernet.de>
Tue, 17 Jun 2014 15:02:20 +0000 (17:02 +0200)
The current code that checks whether the client is allowed to use
pathnames starting with ._ checks whether the file is an AppleDouble
file, and if it is and the filler does not contain the magic string
"Mac OS X", access to the file is denied. This results in the
following sequence of steps:

* client created empty file "._NAME"
* client wants to stat the newly created file "._NAME"
* server checks whether access to the file is allowed
* check fails

Modify check in ad_valid_header_osx() to allow access to all .-
AppleDouble files where the filler string is not "Netatalk", which is
the magic string Netatalk puts there.

Signed-off-by: Ralph Boehme <rb@sernet.de>
NEWS
include/atalk/adouble.h
libatalk/adouble/ad_flush.c
libatalk/adouble/ad_open.c

diff --git a/NEWS b/NEWS
index f4cab3d61e7380d9bd535dc43048a6cc0249d4b9..10b6b61d405bb5e53b271efbfcc761e7326a5bcc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Changes in 3.1.3
 * UPD: Spotlight: more SPARQL query optimisations
 * UPD: Spotlight: new options "sparql results limit", "spotlight
        attributes" and "spotlight expr"
+* FIX: afpd: Unarchiving certain ZIP archives fails, bug #569
 
 Changes in 3.1.2
 ================
index 1881ba028240c0ff5f74edbd162e3d3083e6e5ae..f279d28cc67fb1a691c2320656e1cb2fbb14a1cd 100644 (file)
@@ -348,6 +348,12 @@ struct adouble {
 #define AD_AFPFILEI_GROUP       (1 << 1) /* ignore group */
 #define AD_AFPFILEI_BLANKACCESS (1 << 2) /* blank access permissions */
 
+/*
+ * String identifiers for the 16 AppleDouble filler bytes
+ */
+#define AD_FILLER_NETATALK "Netatalk        "
+#define AD_FILLER_OSX      "Mac OS X"
+
 #define ad_data_fileno(ad)  ((ad)->ad_data_fork.adf_fd)
 #define ad_reso_fileno(ad)  ((ad)->ad_rfp->adf_fd)
 #define ad_meta_fileno(ad)  ((ad)->ad_mdp->adf_fd)
index fc95412c0d5fd03511e83de0c1352f35f1e91551..6e21486302d5a69fd63cffea71788f228384647e 100644 (file)
@@ -164,7 +164,7 @@ int ad_rebuild_adouble_header_osx(struct adouble *ad, char *adbuf)
     memcpy(buf, &temp, sizeof( temp ));
     buf += sizeof( temp );
 
-    memcpy(buf, "Netatalk        ", 16);
+    memcpy(buf, AD_FILLER_NETATALK, strlen(AD_FILLER_NETATALK));
     buf += sizeof( ad->ad_filler );
 
     nent = htons(ADEID_NUM_OSX);
index 0c6af70ac433dccd5a1c65c83f60b5cccfbaffa4..85a32a11518f9296c56cdec84f912aa763286498 100644 (file)
@@ -540,7 +540,9 @@ int ad_valid_header_osx(const char *path)
         EC_FAIL;
     }
 
-    if (strncmp(buf + ADEDOFF_FILLER, "Mac OS X", strlen("Mac OS X")) == 0)
+    if (strncmp(buf + ADEDOFF_FILLER,
+                AD_FILLER_NETATALK,
+                strlen(AD_FILLER_NETATALK)) != 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.