From e41febc84bf8630e945f4e839c04fde106509681 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Wed, 24 Oct 2001 17:25:49 +0000 Subject: Help to recover from bad seek (i.e. negative or too big) happens beyond our pre-check control. Do the same way as refill.c does when it set __SERR, i.e. clear read and ungetc buffers. Clear EOF flag too. --- lib/libc/stdio/stdio.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/libc/stdio/stdio.c') diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c index 4bee60804d4a..7f66fa8ab591 100644 --- a/lib/libc/stdio/stdio.c +++ b/lib/libc/stdio/stdio.c @@ -171,6 +171,13 @@ _sseek(fp, offset, whence) */ if (ret < 0) { if (errret == 0) { + if (offset != 0 || whence != SEEK_CUR) { + if (HASUB(fp)) + FREEUB(fp); + fp->_p = fp->_bf._base; + fp->_r = 0; + fp->_flags &= ~__SEOF; + } fp->_flags |= __SERR; errno = EINVAL; } else if (errret == ESPIPE) -- cgit v1.2.3