forked from Imagelibrary/rtems
Check that the file offset is valid after a seek
This commit is contained in:
@@ -500,21 +500,11 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
off_t
|
||||
msdos_dir_lseek(rtems_libio_t *iop, off_t offset, int whence)
|
||||
{
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
case SEEK_CUR:
|
||||
break;
|
||||
/*
|
||||
* Movement past the end of the directory via lseek is not a
|
||||
* permitted operation
|
||||
*/
|
||||
case SEEK_END:
|
||||
default:
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
break;
|
||||
if (iop->offset >= 0 && iop->offset <= iop->size) {
|
||||
return 0;
|
||||
} else {
|
||||
rtems_set_errno_and_return_minus_one(EINVAL);
|
||||
}
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
/* msdos_dir_stat --
|
||||
|
||||
@@ -231,6 +231,10 @@ msdos_file_lseek(rtems_libio_t *iop, off_t offset, int whence)
|
||||
fat_file_fd_t *fat_fd = iop->pathinfo.node_access;
|
||||
uint32_t real_size = 0;
|
||||
|
||||
if (iop->offset < 0 || iop->offset > UINT32_MAX) {
|
||||
rtems_set_errno_and_return_minus_one(EINVAL);
|
||||
}
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
|
||||
Reference in New Issue
Block a user