]> arthur.barton.de Git - netatalk.git/commitdiff
Fix a crash in of_closefork(), bug #551
authorRalph Boehme <rb@sernet.de>
Thu, 20 Feb 2014 16:06:34 +0000 (17:06 +0100)
committerRalph Boehme <rb@sernet.de>
Thu, 20 Feb 2014 16:18:55 +0000 (17:18 +0100)
Apparently dirlookup() might return NULL when trying to query the did
of an open fork:

    dir = dirlookup(ofork->of_vol, ofork->of_did);

Add a NULL check before using the result.

NEWS
etc/afpd/ofork.c

diff --git a/NEWS b/NEWS
index 9e62be4bf45990a6338f5106a47d6a564b3bb308..8c8fa0a3e0db8c756e8bd778c1d049d7a33b5d44 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Changes in 3.1.1
 * FIX: dbd: remove orphaned ._ AppleDouble files. Bug #549.
 * NEW: afpd: Automatic conversion of ._ AppleDouble files
        created by OS X. Bug #550.
+* FIX: afpd: Fix a crash in of_closefork(). Bug #551.
 
 Changes in 3.1.0
 ================
index cf77d4906ad6edaf0a8dc82c40ba6f75f378be0d..7c975c38f9ed581702e74827aaaf2c2d863e8ce7 100644 (file)
@@ -408,9 +408,11 @@ int of_closefork(const AFPObj *obj, struct ofork *ofork)
     /* Somone has used write_fork, we assume file was changed, register it to file change event api */
     if (ofork->of_flags & AFPFORK_MODIFIED) {
         struct dir *dir =  dirlookup(ofork->of_vol, ofork->of_did);
-        bstring forkpath = bformat("%s/%s", bdata(dir->d_fullpath), of_name(ofork));
-        fce_register(FCE_FILE_MODIFY, bdata(forkpath), NULL, fce_file);
-        bdestroy(forkpath);
+        if (dir) {
+            bstring forkpath = bformat("%s/%s", bdata(dir->d_fullpath), of_name(ofork));
+            fce_register(FCE_FILE_MODIFY, bdata(forkpath), NULL, fce_file);
+            bdestroy(forkpath);
+        }
     }
 
     ad_unlock(ofork->of_ad, ofork->of_refnum, ofork->of_flags & AFPFORK_ERROR ? 0 : 1);