Implement l_len<0 per POSIX check.
Check for valid l_whence too.
This commit is contained in:
parent
ea4313e351
commit
e02faad5ca
@ -102,12 +102,14 @@ nfs_dolock(ap)
|
||||
* the NLM protocol doesn't allow the server to return an error
|
||||
* on ranges, so we do it.
|
||||
*/
|
||||
if (fl->l_len < 0)
|
||||
return (EINVAL);
|
||||
if (fl->l_whence != SEEK_END) {
|
||||
if (fl->l_start < 0)
|
||||
if (fl->l_whence != SEEK_CUR || fl->l_whence != SEEK_SET ||
|
||||
fl->l_start < 0 ||
|
||||
(fl->l_len < 0 &&
|
||||
(fl->l_start == 0 || fl->l_start + fl->l_len < 0)))
|
||||
return (EINVAL);
|
||||
if (fl->l_len != 0 && (fl->l_len - 1 > OFF_MAX - fl->l_start))
|
||||
if (fl->l_len > 0 &&
|
||||
(fl->l_len - 1 > OFF_MAX - fl->l_start))
|
||||
return (EOVERFLOW);
|
||||
}
|
||||
|
||||
|
@ -102,12 +102,14 @@ nfs_dolock(ap)
|
||||
* the NLM protocol doesn't allow the server to return an error
|
||||
* on ranges, so we do it.
|
||||
*/
|
||||
if (fl->l_len < 0)
|
||||
return (EINVAL);
|
||||
if (fl->l_whence != SEEK_END) {
|
||||
if (fl->l_start < 0)
|
||||
if (fl->l_whence != SEEK_CUR || fl->l_whence != SEEK_SET ||
|
||||
fl->l_start < 0 ||
|
||||
(fl->l_len < 0 &&
|
||||
(fl->l_start == 0 || fl->l_start + fl->l_len < 0)))
|
||||
return (EINVAL);
|
||||
if (fl->l_len != 0 && (fl->l_len - 1 > OFF_MAX - fl->l_start))
|
||||
if (fl->l_len > 0 &&
|
||||
(fl->l_len - 1 > OFF_MAX - fl->l_start))
|
||||
return (EOVERFLOW);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user