diff options
Diffstat (limited to 'xlators/features/locks/src/posix.c')
| -rw-r--r-- | xlators/features/locks/src/posix.c | 13 | 
1 files changed, 12 insertions, 1 deletions
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 7dca2d0cb5f..3d79c570bb0 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -1811,12 +1811,23 @@ pl_lk (call_frame_t *frame, xlator_t *this,          posix_lock_t *conf       = NULL;          int           ret        = 0; -        if ((flock->l_start < 0) || (flock->l_len < 0)) { +        if ((flock->l_start < 0) || +            ((flock->l_start + flock->l_len) < 0)) {                  op_ret = -1;                  op_errno = EINVAL;                  goto unwind;          } +        /* As per 'man 3 fcntl', the value of l_len may be +         * negative. In such cases, lock request should be +         * considered for the range starting at 'l_start+l_len' +         * and ending at 'l_start-1'. Update the fields accordingly. +         */ +        if (flock->l_len < 0) { +                flock->l_start += flock->l_len; +                flock->l_len = abs (flock->l_len); +        } +          pl_inode = pl_inode_get (this, fd->inode);          if (!pl_inode) {                  op_ret = -1;  | 
