Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 9986
b: refs/heads/master
c: 4c780a4
h: refs/heads/master
v: v3
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Oct 18, 2005
1 parent d90218e commit e29b3c7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 550f57470c6506f5ef3c708335dea6bd48bf3dc4
refs/heads/master: 4c780a4688b421baa896b59778c05d7e068e479f
42 changes: 25 additions & 17 deletions trunk/fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,21 +316,22 @@ static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
/* POSIX-1996 leaves the case l->l_len < 0 undefined;
POSIX-2001 defines it. */
start += l->l_start;
end = start + l->l_len - 1;
if (l->l_len < 0) {
if (start < 0)
return -EINVAL;
fl->fl_end = OFFSET_MAX;
if (l->l_len > 0) {
end = start + l->l_len - 1;
fl->fl_end = end;
} else if (l->l_len < 0) {
end = start - 1;
fl->fl_end = end;
start += l->l_len;
if (start < 0)
return -EINVAL;
}

if (start < 0)
return -EINVAL;
if (l->l_len > 0 && end < 0)
return -EOVERFLOW;

fl->fl_start = start; /* we record the absolute position */
fl->fl_end = end;
if (l->l_len == 0)
fl->fl_end = OFFSET_MAX;
if (fl->fl_end < fl->fl_start)
return -EOVERFLOW;

fl->fl_owner = current->files;
fl->fl_pid = current->tgid;
Expand Down Expand Up @@ -362,14 +363,21 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
return -EINVAL;
}

if (((start += l->l_start) < 0) || (l->l_len < 0))
start += l->l_start;
if (start < 0)
return -EINVAL;
fl->fl_end = start + l->l_len - 1;
if (l->l_len > 0 && fl->fl_end < 0)
return -EOVERFLOW;
fl->fl_end = OFFSET_MAX;
if (l->l_len > 0) {
fl->fl_end = start + l->l_len - 1;
} else if (l->l_len < 0) {
fl->fl_end = start - 1;
start += l->l_len;
if (start < 0)
return -EINVAL;
}
fl->fl_start = start; /* we record the absolute position */
if (l->l_len == 0)
fl->fl_end = OFFSET_MAX;
if (fl->fl_end < fl->fl_start)
return -EOVERFLOW;

fl->fl_owner = current->files;
fl->fl_pid = current->tgid;
Expand Down

0 comments on commit e29b3c7

Please sign in to comment.