]> arthur.barton.de Git - netatalk.git/commitdiff
Fix a possible crash when searching on large volumes
authorRalph Boehme <sloowfranklin@gmail.com>
Tue, 11 Dec 2012 12:42:12 +0000 (13:42 +0100)
committerRalph Boehme <sloowfranklin@gmail.com>
Tue, 11 Dec 2012 15:00:40 +0000 (16:00 +0100)
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.

etc/afpd/catsearch.c

index 946644fb73ec63adbb91fd1753195c1577ea5bc0..1a2b898910f14e574743424f4ad2480ea65a3203 100644 (file)
@@ -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(".");