Skip to content

Commit

Permalink
Fix mounting on FreeBSD
Browse files Browse the repository at this point in the history
Currently, mounting on FreeBSD fails like this:

 mount_fusefs: ZZZZ<snip> on /mountpoint: No such file or directory

This happens because right after doing argv[a++] = fdnam it's
getting freed before calling execvp().

So move this free() call after execvp(). Also, when asprintf()
fails for fdnam, close device fd before calling exit().
  • Loading branch information
novel authored and Nikratio committed Nov 11, 2018
1 parent 70e25ea commit 11d9ed6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/mount_bsd.c
Expand Up @@ -222,6 +222,7 @@ static int fuse_mount_core(const char *mountpoint, const char *opts)
if(ret == -1)
{
perror("fuse: failed to assemble mount arguments");
close(fd);
exit(1);
}
}
Expand All @@ -232,14 +233,11 @@ static int fuse_mount_core(const char *mountpoint, const char *opts)
argv[a++] = opts;
}
argv[a++] = fdnam;

if(ret != -1)
free(fdnam);

argv[a++] = mountpoint;
argv[a++] = NULL;
execvp(mountprog, (char **) argv);
perror("fuse: failed to exec mount program");
free(fdnam);
exit(1);
}

Expand Down

0 comments on commit 11d9ed6

Please sign in to comment.