diff options
author | ache <ache@FreeBSD.org> | 2001-08-17 11:08:56 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-08-17 11:08:56 +0000 |
commit | b2c8d2cea9db9a1bf173d82e02a0379898377613 (patch) | |
tree | 72a07cae8f84cd50f29c04aae833a00360e7f672 /lib/libc/stdio | |
parent | a95746d6e34166b1b314544deb28cbd772c150e0 (diff) | |
download | FreeBSD-src-b2c8d2cea9db9a1bf173d82e02a0379898377613.zip FreeBSD-src-b2c8d2cea9db9a1bf173d82e02a0379898377613.tar.gz |
Simplify overflow calculations a bit
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r-- | lib/libc/stdio/fseek.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index 5af0bac..0e77b1e 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -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); } |