From 0aa053745904c0c842c8ac7a81f804839406a29f Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 8 Jan 2020 09:33:46 +0100 Subject: [PATCH] Fix possible segmentation fault in direct_fsync() If the call to `get_upper_layer(lo)` returns `NULL` then the `node->layer` will be `NULL`, too. If this is the case we pass `NULL` to `direct_fsync()` which will cause a segmentation fault in: ```c cfd = openat(l->fd, path, O_NOFOLLOW|O_DIRECTORY); ``` To fix this we now apply an additional check and error in the case of `get_upper_layer(lo) == NULL`. Signed-off-by: Sascha Grunert --- main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.c b/main.c index c006fc5..0a6cf38 100644 --- a/main.c +++ b/main.c @@ -4595,6 +4595,12 @@ do_fsync (fuse_req_t req, fuse_ino_t ino, int datasync, int fd) /* Skip fsync for lower layers. */ do_fsync = node && node->layer == get_upper_layer (lo); + if (node->layer == NULL) + { + fuse_reply_err (req, ENOENT); + return; + } + if (fd < 0) strcpy (path, node->path);