From: Ralph Boehme Date: Thu, 20 Feb 2014 16:06:34 +0000 (+0100) Subject: Fix a crash in of_closefork(), bug #551 X-Git-Url: https://arthur.barton.de/gitweb/?p=netatalk.git;a=commitdiff_plain;h=40ec4cf6aa9f58d91a7b11f562163b0ffb3b86f4 Fix a crash in of_closefork(), bug #551 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. --- diff --git a/NEWS b/NEWS index 9e62be4b..8c8fa0a3 100644 --- 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 ================ diff --git a/etc/afpd/ofork.c b/etc/afpd/ofork.c index cf77d490..7c975c38 100644 --- a/etc/afpd/ofork.c +++ b/etc/afpd/ofork.c @@ -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);