diff options
author | Matthias Görgens <matthias.goergens@gmail.com> | 2023-06-08 18:47:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-08 11:47:45 +0100 |
commit | e0041ada71d923e5babe5f9a0df6da31a6dbd039 (patch) | |
tree | 3859afada9fb1c909dd436f3e0ee19494aa1a902 | |
parent | 690b12f0005b66786a62f867daccb210e2390d2b (diff) | |
download | libfuse-e0041ada71d923e5babe5f9a0df6da31a6dbd039.tar.gz |
Error handling for fusermount's commfd (#786)
-rw-r--r-- | util/fusermount.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/util/fusermount.c b/util/fusermount.c index 06f2461..57bf3ed 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -1453,6 +1453,16 @@ int main(int argc, char *argv[]) } cfd = atoi(commfd); + { + struct stat statbuf; + fstat(cfd, &statbuf); + if(!S_ISSOCK(statbuf.st_mode)) { + fprintf(stderr, + "%s: file descriptor %i is not a socket, can't send fuse fd\n", + progname, cfd); + goto err_out; + } + } if (setup_auto_unmount_only) goto wait_for_auto_unmount; @@ -1462,8 +1472,10 @@ int main(int argc, char *argv[]) goto err_out; res = send_fd(cfd, fd); - if (res == -1) + if (res != 0) { + umount2(mnt, MNT_DETACH); /* lazy umount */ goto err_out; + } close(fd); if (!auto_unmount) { |