Skip to content

Commit 4ad194b

Browse files
authored
[fix] fix cromfs read out of mem range (#9197)
Update dfs_cromfs.c
1 parent 1d78d11 commit 4ad194b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

components/dfs/dfs_v2/filesystems/cromfs/dfs_cromfs.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -786,18 +786,18 @@ static ssize_t dfs_cromfs_read(struct dfs_file *file, void *buf, size_t count, o
786786
rt_err_t result = RT_EOK;
787787
file_info *fi = NULL;
788788
cromfs_info *ci = NULL;
789-
uint32_t length = 0;
789+
ssize_t length = 0;
790790

791791
ci = (cromfs_info *)file->dentry->mnt->data;
792792
fi = (file_info *)file->vnode->data;
793793

794-
if (count < file->vnode->size - *pos)
794+
if ((off_t)count < (off_t)file->vnode->size - *pos)
795795
{
796796
length = count;
797797
}
798798
else
799799
{
800-
length = file->vnode->size - *pos;
800+
length = (off_t)file->vnode->size - *pos;
801801
}
802802

803803
if (length > 0)

0 commit comments

Comments
 (0)