Today we return EINVAL for fcntl with a lock with negative length.
POSIX-2001 says that the lock covers start .. start+len-1 if len >= 0
and start+len .. start-1 if len < 0.
return -EINVAL;
}
- if (((start += l->l_start) < 0) || (l->l_len < 0))
- return -EINVAL;
+ /* 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) {
+ end = start - 1;
+ start += l->l_len;
+ }
+
+ 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)