From: Ralph Boehme Date: Tue, 11 Dec 2012 12:42:12 +0000 (+0100) Subject: Fix a possible crash when searching on large volumes X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=7d260cdde7b048b1bb7bb61ea396ac9c3ce677de Fix a possible crash when searching on large volumes catsearch() used dirlookup() to lookup directories, but then it didn't use movecwd() to cd into them, only lchdir(). This resulted in curdir not being updated. Then, while processing entries of directory and adding them to the dircache, in case the dircache hit its maximum size limit, dircache eviction would take place. The dircache eviction will remove a fixed size number of directories from the cache, but for every entry to be freed it will ensure that it's nor curdir. Unfortunately as catsearch didn't update that, the directory that catsearch was working on was freed, which of course resulted in access of invalid ressouces and possible crashes. The fix is to just use movecwd() instead of lchdir()ing directly. --- diff --git a/etc/afpd/catsearch.c b/etc/afpd/catsearch.c index 946644fb..1a2b8989 100644 --- a/etc/afpd/catsearch.c +++ b/etc/afpd/catsearch.c @@ -545,7 +545,7 @@ static int catsearch(const AFPObj *obj, } LOG(log_debug, logtype_afpd, "catsearch: current struct dir: \"%s\"", cfrombstr(currentdir->d_fullpath)); - error = lchdir(bdata(currentdir->d_fullpath)); + error = movecwd(vol, currentdir); if (!error && dirpos == NULL) dirpos = opendir(".");