fs/fat/fs_fat32.c Return EOF when reading past the end of the file.

When fseek is used to set the file pointer past the end of the file,
fread should return EOF. See #12496.
This commit is contained in:
Stuart Ianna 2024-06-24 12:29:36 +10:00 committed by Xiang Xiao
parent 9790248f9a
commit 3b4626acc8

View File

@ -535,6 +535,16 @@ static ssize_t fat_read(FAR struct file *filep, FAR char *buffer,
goto errout_with_lock;
}
/* Check that the file position is not past the end of the file */
if (filep->f_pos > ff->ff_size)
{
/* Return EOF */
ret = 0;
goto errout_with_lock;
}
/* Get the number of bytes left in the file */
bytesleft = ff->ff_size - filep->f_pos;