From: legezywzh <94814730+legezywzh@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:23:57 +0000 (+0800) Subject: fix max_write update in do_init() (#926) X-Git-Tag: fuse-3.17.1-rc0~132 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=080077369e7fa740da7d9813e6766c308e4e555c;p=qemu-gpiodev%2Flibfuse.git fix max_write update in do_init() (#926) If user updates conn->max_write in fuse_lowlevel_ops' init() method, do_init() will miss the "conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE" judgment, and ->init method will be called after it, which obviously is a bug. Signed-off-by: Xiaoguang Wang Co-authored-by: Xiaoguang Wang --- diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index d9844b0..5129a3b 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -2079,13 +2079,13 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) } se->bufsize = bufsize; - if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE) - se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE; - se->got_init = 1; if (se->op.init) se->op.init(se->userdata, &se->conn); + if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE) + se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE; + if (se->conn.want & (~se->conn.capable)) { fuse_log(FUSE_LOG_ERR, "fuse: error: filesystem requested capabilities " "0x%x that are not supported by kernel, aborting.\n",