mirror of
https://github.com/devkitPro/wut.git
synced 2026-08-24 11:44:17 -05:00
wutdevoptab: Prevent file-offset overflow in seek implementation
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user