summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1996-12-19 13:22:30 +0000
committerBruce Evans <bde@FreeBSD.org>1996-12-19 13:22:30 +0000
commita88bd8aae47d54bcedbe1edbd09eec7a890499b9 (patch)
tree7819fd58e70014e99e79a4fcbb577c4b83a0f629
parent0181a94ac9366e31d2e83de80f403f8aa2411212 (diff)
Notes
-rw-r--r--sys/kern/kern_lockf.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c
index 98b324017ce1..ffe31b153d21 100644
--- a/sys/kern/kern_lockf.c
+++ b/sys/kern/kern_lockf.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_lockf.c 8.3 (Berkeley) 1/6/94
- * $Id: kern_lockf.c,v 1.5 1995/12/14 08:31:26 phk Exp $
+ * $Id: kern_lockf.c,v 1.6 1996/09/03 14:21:52 bde Exp $
*/
#include <sys/param.h>
@@ -93,15 +93,6 @@ lf_advlock(ap, head, size)
int error;
/*
- * Avoid the common case of unlocking when inode has no locks.
- */
- if (*head == (struct lockf *)0) {
- if (ap->a_op != F_SETLK) {
- fl->l_type = F_UNLCK;
- return (0);
- }
- }
- /*
* Convert the flock structure into a start and end.
*/
switch (fl->l_whence) {
@@ -126,8 +117,20 @@ lf_advlock(ap, head, size)
return (EINVAL);
if (fl->l_len == 0)
end = -1;
- else
+ else {
end = start + fl->l_len - 1;
+ if (end < start)
+ return (EINVAL);
+ }
+ /*
+ * Avoid the common case of unlocking when inode has no locks.
+ */
+ if (*head == (struct lockf *)0) {
+ if (ap->a_op != F_SETLK) {
+ fl->l_type = F_UNLCK;
+ return (0);
+ }
+ }
/*
* Create the lockf structure
*/