]> arthur.barton.de Git - netatalk.git/commitdiff
fd leak when using appledouble = v2, bug #554
authorRalph Boehme <rb@sernet.de>
Wed, 21 May 2014 14:59:38 +0000 (16:59 +0200)
committerRalph Boehme <rb@sernet.de>
Wed, 21 May 2014 14:59:38 +0000 (16:59 +0200)
With appledouble = v2 in afp.conf there is an fd leak in certain
circumstances while using the Finder, from Daniel Hazelbaker.

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

diff --git a/NEWS b/NEWS
index 6ed64ee6c5d3e96efd5c7e41cf690f4fc7c7d2b1..f6fd71a1fd52d26eb67d76757a7cdc004bce141a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Changes in 3.1.2
 * NEW: afpd: support for using $u username variable in AFP volume
        definitions. FR#90.
 * FIX: getvolbypath returns incorrect volume, bug #563
+* FIX: fd leak when using appledouble = v2, bug #554
 
 Changes in 3.1.1
 ================
index 76d44a98051a6820fc3c666491efec9beab499bb..fc95412c0d5fd03511e83de0c1352f35f1e91551 100644 (file)
@@ -429,6 +429,17 @@ int ad_close(struct adouble *ad, int adflags)
     }
 
     if (adflags & ADFLAGS_RF) {
+        /* HF is automatically opened when opening an RF, close it. */
+        if ((ad->ad_vers == AD_VERSION2) && (ad_meta_fileno(ad) != -1)) {
+            if (ad->ad_meta_refcount)
+                ad->ad_meta_refcount--;
+            if (!(--ad->ad_mdp->adf_refcount)) {
+                if (close( ad_meta_fileno(ad)) < 0)
+                    err = -1;
+                ad_meta_fileno(ad) = -1;
+            }
+        }
+
         if (ad->ad_reso_refcount)
             if (--ad->ad_reso_refcount == 0)
                 adf_lock_free(ad->ad_rfp);