OSDN Git Service

tools/virtiofsd/buffer.c: check whether buf is NULL in fuse_bufvec_advance func
authorHaotian Li <lihaotian9@huawei.com>
Wed, 11 Nov 2020 01:05:56 +0000 (09:05 +0800)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Thu, 12 Nov 2020 16:25:23 +0000 (16:25 +0000)
In fuse_bufvec_advance func, calling fuse_bufvec_current func
may return NULL, so we should check whether buf is NULL before
using it.

Signed-off-by: Haotian Li <lihaotian9@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Message-Id: <29fc87c2-b87c-4c34-40d4-75381f228849@huawei.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
tools/virtiofsd/buffer.c

index 27c1377..bdc608c 100644 (file)
@@ -246,6 +246,10 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv, size_t len)
 {
     const struct fuse_buf *buf = fuse_bufvec_current(bufv);
 
+    if (!buf) {
+        return 0;
+    }
+
     bufv->off += len;
     assert(bufv->off <= buf->size);
     if (bufv->off == buf->size) {