summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-08-23 17:01:25 +0000
committerache <ache@FreeBSD.org>2001-08-23 17:01:25 +0000
commit1dabef88453571cb8dd7bd9fe90813f7dfb937a7 (patch)
treebaa68ed25d1ec5bc1ee2a9f693bfe24e5e9f1bdd /sys
parent86b9c464000d23c229251d06e9af10b10ab21308 (diff)
downloadFreeBSD-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.c3
-rw-r--r--sys/kern/vfs_syscalls.c3
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;
OpenPOWER on IntegriCloud