]> arthur.barton.de Git - netatalk.git/commitdiff
Fix "ad ls" segfault if requested object is not in an AFP volume
authorRalph Boehme <sloowfranklin@gmail.com>
Fri, 22 Mar 2013 12:53:10 +0000 (13:53 +0100)
committerRalph Boehme <sloowfranklin@gmail.com>
Sun, 24 Mar 2013 08:36:49 +0000 (09:36 +0100)
Fixes bug #496.

NEWS
bin/ad/ad_ls.c
bin/ad/ad_util.c

diff --git a/NEWS b/NEWS
index 0828927a6bc80cafa92772d6163761469e0f0c03..c85c245dd005e4029d29abb2f8944b291c475bc6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -44,6 +44,8 @@ Changes in 3.0.3
        Fixes bug #508.
 * FIX: Setting POSIX ACLs on Linux
        Fixes bug #506.
+* FIX: "ad ls" segfault if requested object is not in an AFP volume.
+       Fixes bug #496.
 
 Changes in 3.0.2
 ================
index d8362595e4647a7ef54098d4f1711b5b45b5b2ce..b5947e17dd0b48c3fa7d12e477128989372fe38d 100644 (file)
@@ -227,7 +227,7 @@ static void print_flags(char *path, afpvol_t *vol, const struct stat *st)
     if (S_ISDIR(st->st_mode))
         adflags = ADFLAGS_DIR;
 
-    if (vol->vol->v_path == NULL)
+    if (vol->vol == NULL || vol->vol->v_path == NULL)
         return;
 
     ad_init(&ad, vol->vol);
index 897bdf3b1415c609efdae24f2104d019ef3464fc..fbe85235c2af51201ec331e5e0ea67d27ed93f86 100644 (file)
@@ -138,9 +138,11 @@ int openvol(AFPObj *obj, const char *path, afpvol_t *vol)
 
 void closevol(afpvol_t *vol)
 {
-    if (vol->vol->v_cdb) {
-        cnid_close(vol->vol->v_cdb);
-        vol->vol->v_cdb = NULL;
+    if (vol->vol) {
+        if (vol->vol->v_cdb) {
+            cnid_close(vol->vol->v_cdb);
+            vol->vol->v_cdb = NULL;
+        }
     }
     memset(vol, 0, sizeof(afpvol_t));
 }