diff options
author | ache <ache@FreeBSD.org> | 2001-08-23 17:01:25 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-08-23 17:01:25 +0000 |
commit | 1dabef88453571cb8dd7bd9fe90813f7dfb937a7 (patch) | |
tree | baa68ed25d1ec5bc1ee2a9f693bfe24e5e9f1bdd /sys | |
parent | 86b9c464000d23c229251d06e9af10b10ab21308 (diff) | |
download | FreeBSD-src-1dabef88453571cb8dd7bd9fe90813f7dfb937a7.zip FreeBSD-src-1dabef88453571cb8dd7bd9fe90813f7dfb937a7.tar.gz |
lseek: fix check for vattr.va_size overflow. Check suggested by bde simple not
works with unsigned types.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_extattr.c | 3 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 78fff15..f6321a2 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -1640,9 +1640,10 @@ lseek(p, uap) error = VOP_GETATTR(vp, &vattr, cred, p); if (error) return (error); + /* 'vattr.va_size' is always >= 0 */ if (noneg && ((offset > 0 && vattr.va_size > OFF_MAX - offset) || - (offset < 0 && vattr.va_size < OFF_MIN - offset))) + (offset < 0 && vattr.va_size + offset > OFF_MAX))) return (EOVERFLOW); offset += vattr.va_size; break; diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 78fff15..f6321a2 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1640,9 +1640,10 @@ lseek(p, uap) error = VOP_GETATTR(vp, &vattr, cred, p); if (error) return (error); + /* 'vattr.va_size' is always >= 0 */ if (noneg && ((offset > 0 && vattr.va_size > OFF_MAX - offset) || - (offset < 0 && vattr.va_size < OFF_MIN - offset))) + (offset < 0 && vattr.va_size + offset > OFF_MAX))) return (EOVERFLOW); offset += vattr.va_size; break; |