aboutsummaryrefslogtreecommitdiff
path: root/sys/nfs/nfs_lock.c
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2001-08-23 08:20:21 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2001-08-23 08:20:21 +0000
commite9d095afdc26cc31afa7ed3b3f138d3719636091 (patch)
tree42813e99aa0cc29b800224ccb7de2239bee5244f /sys/nfs/nfs_lock.c
parent69cc1d0d7f3445d3671e05dcb7baabe7e36c5ed9 (diff)
downloadsrc-e9d095afdc26cc31afa7ed3b3f138d3719636091.tar.gz
src-e9d095afdc26cc31afa7ed3b3f138d3719636091.zip
adv. lock:
detect off_t overflow _before_ it occurse and return EOVERFLOW instead of EINVAL
Notes
Notes: svn path=/head/; revision=82174
Diffstat (limited to 'sys/nfs/nfs_lock.c')
-rw-r--r--sys/nfs/nfs_lock.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/nfs/nfs_lock.c b/sys/nfs/nfs_lock.c
index 9e28eeb8a600..94b5df1c999a 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.