diff options
author | ache <ache@FreeBSD.org> | 2001-08-23 08:20:21 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-08-23 08:20:21 +0000 |
commit | e955b0b7351ef5c6131fda8bc95135858de68d0d (patch) | |
tree | 42813e99aa0cc29b800224ccb7de2239bee5244f /sys | |
parent | 1905060cac646380cb34d8c69b70c28b52278798 (diff) | |
download | FreeBSD-src-e955b0b7351ef5c6131fda8bc95135858de68d0d.zip FreeBSD-src-e955b0b7351ef5c6131fda8bc95135858de68d0d.tar.gz |
adv. lock:
detect off_t overflow _before_ it occurse and return EOVERFLOW instead of
EINVAL
Diffstat (limited to 'sys')
-rw-r--r-- | sys/nfs/nfs_lock.c | 10 | ||||
-rw-r--r-- | sys/nfsclient/nfs_lock.c | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c index 9e28eeb..94b5df1 100644 --- a/sys/nfs/nfs_lock.c +++ b/sys/nfs/nfs_lock.c @@ -29,6 +29,7 @@ * $FreeBSD$ */ +#include <machine/limits.h> #include <sys/param.h> #include <sys/systm.h> #include <sys/fcntl.h> @@ -98,13 +99,12 @@ nfs_dolock(ap) /* * the NLM protocol doesn't allow the server to return an error - * on ranges, so we do it. Note that we should be returning - * EOVERFLOW in some cases, but we don't have it. + * on ranges, so we do it. */ - if (fl->l_start < 0 || fl->l_len < 0 || - ((fl->l_len != 0 && - (fl->l_start + fl->l_len - 1) < 0))) + if (fl->l_start < 0 || fl->l_len < 0) return (EINVAL); + if (fl->l_len != 0 && (fl->l_len - 1 > OFF_MAX - fl->l_start)) + return (EOVERFLOW); /* * Fill in the information structure. diff --git a/sys/nfsclient/nfs_lock.c b/sys/nfsclient/nfs_lock.c index 9e28eeb..94b5df1 100644 --- a/sys/nfsclient/nfs_lock.c +++ b/sys/nfsclient/nfs_lock.c @@ -29,6 +29,7 @@ * $FreeBSD$ */ +#include <machine/limits.h> #include <sys/param.h> #include <sys/systm.h> #include <sys/fcntl.h> @@ -98,13 +99,12 @@ nfs_dolock(ap) /* * the NLM protocol doesn't allow the server to return an error - * on ranges, so we do it. Note that we should be returning - * EOVERFLOW in some cases, but we don't have it. + * on ranges, so we do it. */ - if (fl->l_start < 0 || fl->l_len < 0 || - ((fl->l_len != 0 && - (fl->l_start + fl->l_len - 1) < 0))) + if (fl->l_start < 0 || fl->l_len < 0) return (EINVAL); + if (fl->l_len != 0 && (fl->l_len - 1 > OFF_MAX - fl->l_start)) + return (EOVERFLOW); /* * Fill in the information structure. |