mirror of
https://github.com/devkitPro/wut.git
synced 2026-03-21 17:34:47 -05:00
wutdevoptab: Prevent file-offset overflow in seek implementation
This commit is contained in:
parent
3469036c44
commit
a902da1ce7
|
|
@ -49,11 +49,14 @@ __wut_fs_seek(struct _reent *r,
|
|||
return -1;
|
||||
}
|
||||
|
||||
// TODO: A better check that prevents overflow.
|
||||
if(pos < 0 && offset < -pos) {
|
||||
// Don't allow seek to before the beginning of the file
|
||||
r->_errno = EINVAL;
|
||||
return -1;
|
||||
} else if (offset + pos > UINT32_MAX) {
|
||||
// Check for overflow
|
||||
r->_errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t old_offset = file->offset;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user