Skip to content

Commit

Permalink
Fix "ad ls" segfault if requested object is not in an AFP volume
Browse files Browse the repository at this point in the history
Fixes bug #496.
  • Loading branch information
slowfranklin committed Mar 24, 2013
1 parent 7a54dad commit 8764a9e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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
================
Expand Down
2 changes: 1 addition & 1 deletion bin/ad/ad_ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions bin/ad/ad_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 8764a9e

Please sign in to comment.