diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 78fff1570ad5..f6321a262640 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 78fff1570ad5..f6321a262640 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;