Simplify overflow calculations a bit
This commit is contained in:
parent
4a9f1ee4e5
commit
98aa5183a2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81822
@ -144,8 +144,7 @@ _fseeko(fp, offset, whence, ltest)
|
||||
curoff += fp->_p - fp->_bf._base;
|
||||
|
||||
/* curoff always >= 0 */
|
||||
if (offset > 0 &&
|
||||
curoff > (ltest ? LONG_MAX : OFF_MAX) - offset) {
|
||||
if (offset > 0 && curoff > OFF_MAX - offset) {
|
||||
errno = EOVERFLOW;
|
||||
return (EOF);
|
||||
}
|
||||
@ -212,8 +211,7 @@ _fseeko(fp, offset, whence, ltest)
|
||||
if (_fstat(fp->_file, &st))
|
||||
goto dumb;
|
||||
/* st.st_size always >= 0 */
|
||||
if (offset > 0 &&
|
||||
st.st_size > (ltest ? LONG_MAX : OFF_MAX) - offset) {
|
||||
if (offset > 0 && st.st_size > OFF_MAX - offset) {
|
||||
errno = EOVERFLOW;
|
||||
return (EOF);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user