summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/locks/src/posix.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 8d1e67e703c..dae881d4f20 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -1806,12 +1806,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;