Make fseek(... SEEK_CUR) fails if current file-position is unspecified.
This commit is contained in:
parent
6c12b81f9e
commit
8f0ae93dff
@ -206,12 +206,8 @@ for
|
|||||||
and
|
and
|
||||||
.Fn ftell .
|
.Fn ftell .
|
||||||
.It Bq Er ESPIPE
|
.It Bq Er ESPIPE
|
||||||
The file descriptor underlying stream is associated with a pipe or FIFO.
|
The file descriptor underlying stream is associated with a pipe or FIFO
|
||||||
For
|
or file-position indicator value is unspecified
|
||||||
.Fn ftell
|
|
||||||
and
|
|
||||||
.Fn ftello ,
|
|
||||||
file-position indicator value is unspecified
|
|
||||||
(see
|
(see
|
||||||
.Xr ungetc 3 ) .
|
.Xr ungetc 3 ) .
|
||||||
.El
|
.El
|
||||||
|
@ -131,8 +131,12 @@ _fseeko(fp, offset, whence, ltest)
|
|||||||
*/
|
*/
|
||||||
if (_ftello(fp, &curoff))
|
if (_ftello(fp, &curoff))
|
||||||
return (-1);
|
return (-1);
|
||||||
if ((offset > 0 && curoff > OFF_MAX - offset) ||
|
if (curoff < 0) {
|
||||||
(offset < 0 && curoff < OFF_MIN - offset)) {
|
/* Unspecified position because of ungetc() at 0 */
|
||||||
|
errno = ESPIPE;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (offset > 0 && curoff > OFF_MAX - offset) {
|
||||||
errno = EOVERFLOW;
|
errno = EOVERFLOW;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user