diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 2001-08-15 20:10:38 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 2001-08-15 20:10:38 +0000 |
| commit | 74b27728248e2036aabdf3d8d5e36bf735972bdb (patch) | |
| tree | d29af930221032c30f15dad72ba84a6df225095a /lib/libc/stdio/fseek.c | |
| parent | ca0bdcdd29435ccaab5aa0c347f43c5a08031b16 (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdio/fseek.c')
| -rw-r--r-- | lib/libc/stdio/fseek.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index d311f7a5e1c2..c357370d917c 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -45,10 +45,11 @@ static const char rcsid[] = #include "namespace.h" #include <sys/types.h> #include <sys/stat.h> +#include <errno.h> #include <fcntl.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> -#include <errno.h> #include "un-namespace.h" #include "local.h" #include "libc_private.h" @@ -132,7 +133,8 @@ _fseeko(fp, offset, whence) } else if (fp->_flags & __SWR && fp->_p != NULL) curoff += fp->_p - fp->_bf._base; - if (offset > 0 && offset + (off_t)curoff < 0) { + /* curoff always >= 0 */ + if (offset > 0 && curoff > OFF_MAX - offset) { errno = EOVERFLOW; return (EOF); } @@ -194,7 +196,8 @@ _fseeko(fp, offset, whence) else { if (_fstat(fp->_file, &st)) goto dumb; - if (offset > 0 && st.st_size + offset < 0) { + /* st.st_size always >= 0 */ + if (offset > 0 && st.st_size > OFF_MAX - offset) { errno = EOVERFLOW; return (EOF); } |
