diff --git a/fs/v9fs/client.c b/fs/v9fs/client.c index e00fdc7cee1..ab5589b5721 100644 --- a/fs/v9fs/client.c +++ b/fs/v9fs/client.c @@ -1024,7 +1024,8 @@ ssize_t v9fs_client_convertdir(FAR const uint8_t *buffer, size_t bufsize, * (qid, offset, type, name_len) */ - if (bufsize < V9FS_QIDSZ + V9FS_BIT64SZ + V9FS_BIT8SZ + V9FS_BIT16SZ) + if (bufsize - head < V9FS_QIDSZ + V9FS_BIT64SZ + V9FS_BIT8SZ + + V9FS_BIT16SZ) { return -EIO; } diff --git a/fs/v9fs/v9fs.c b/fs/v9fs/v9fs.c index b039008e99f..f6777035612 100644 --- a/fs/v9fs/v9fs.c +++ b/fs/v9fs/v9fs.c @@ -627,6 +627,16 @@ static int v9fs_vfs_readdir(FAR struct inode *mountpt, break; } + /* The server returns no entries at the end of the directory. + * -ENOENT tells the VFS that this is the end, not an error. + */ + + if (ret == 0) + { + ret = -ENOENT; + break; + } + fsdir->head = 0; fsdir->size = ret; }