From: Frank Lahm Date: Tue, 9 Oct 2012 16:23:57 +0000 (+0200) Subject: Fix a bug where Mac OS X ZIP archives can't be extracted on Netatalk shares X-Git-Url: https://arthur.barton.de/gitweb/?a=commitdiff_plain;ds=sidebyside;h=23e45f681099477f57a58740016ed666e8c4d284;p=netatalk.git Fix a bug where Mac OS X ZIP archives can't be extracted on Netatalk shares 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. --- diff --git a/libatalk/adouble/ad_flush.c b/libatalk/adouble/ad_flush.c index a637b27f..91f8058b 100644 --- a/libatalk/adouble/ad_flush.c +++ b/libatalk/adouble/ad_flush.c @@ -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); diff --git a/libatalk/adouble/ad_open.c b/libatalk/adouble/ad_open.c index 3e06e93f..045c33c3 100644 --- a/libatalk/adouble/ad_open.c +++ b/libatalk/adouble/ad_open.c @@ -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)