lseek: fix check for vattr.va_size overflow. Check suggested by bde simple not

works with unsigned types.
This commit is contained in:
Andrey A. Chernov 2001-08-23 17:01:25 +00:00
parent e02faad5ca
commit db106eff39
2 changed files with 4 additions and 2 deletions

View File

@ -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;

View File

@ -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;