If lseek to wrong value sucessfully happens despite all pre-checks, set __SERR

to indicate that stream becomes inconsistent.
This commit is contained in:
Andrey A. Chernov 2001-09-01 11:21:28 +00:00
parent b13ed88361
commit 6946977c36
2 changed files with 4 additions and 1 deletions

View File

@ -297,6 +297,7 @@ _fseeko(fp, offset, whence, ltest)
(*seekfn)(fp->_cookie, (fpos_t)offset, whence) == POS_ERR)
return (-1);
if (ltest && fp->_offset > LONG_MAX) {
fp->_flags |= __SERR;
errno = EOVERFLOW;
return (-1);
}

View File

@ -118,8 +118,10 @@ __sseek(cookie, offset, whence)
* (fseek) in the cases it can't detect.
*/
if (ret < 0) {
if (errret == 0)
if (errret == 0) {
fp->_flags |= __SERR;
errno = EINVAL;
}
fp->_flags &= ~__SOFF;
ret = -1;
} else {