]> arthur.barton.de Git - netatalk.git/blobdiff - bin/ad/ad_ls.c
Fix "ad ls" segfault if requested object is not in an AFP volume
[netatalk.git] / bin / ad / ad_ls.c
index 8cda318a99d2e4afe04ffa4392e981d10d542909..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);
@@ -594,7 +594,7 @@ exit:
     return ret;
 }
 
-int ad_ls(int argc, char **argv)
+int ad_ls(int argc, char **argv, AFPObj *obj)
 {
     int c, firstarg;
     afpvol_t vol;
@@ -630,7 +630,7 @@ int ad_ls(int argc, char **argv)
     cnid_init();
 
     if ((argc - optind) == 0) {
-        openvol(".", &vol);
+        openvol(obj, ".", &vol);
         ad_ls_r(".", &vol);
         closevol(&vol);
     }
@@ -650,7 +650,7 @@ int ad_ls(int argc, char **argv)
             first = 1;
             recursion = 0;
 
-            openvol(argv[optind], &vol);
+            openvol(obj, argv[optind], &vol);
             ad_ls_r(argv[optind], &vol);
             closevol(&vol);
         next:
@@ -672,7 +672,7 @@ int ad_ls(int argc, char **argv)
             first = 1;
             recursion = 0;
 
-            openvol(argv[optind], &vol);
+            openvol(obj, argv[optind], &vol);
             ad_ls_r(argv[optind], &vol);
             closevol(&vol);