Opened 11 years ago

Closed 11 years ago

#273 closed defect (fixed)

fcntl() fails

Reported by: Silvan Scherrer Owned by: Silvan Scherrer
Priority: highest Milestone: libc-0.6.6
Component: libc Version:
Severity: blocker Keywords:
Cc:

Description

given this code:

fl.l_type = rw;
fl.l_whence = SEEK_SET;
fl.l_start = off;
fl.l_len = len;
fl.l_pid = 0;
if (waitflag)
     return fcntl(tdb->fd, F_SETLKW, &fl);
else
return fcntl(tdb->fd, F_SETLK, &fl);

where len == 0 and off == 692

libc produces this log:

014759df 01 04 0004 Entr 0000 __fcntl_locking: fh=3 iRequest=9 pFlock=0x025bedf8
014759df 01 04 0004 ErrL 0000 __fcntl_locking (0 ms): D:/CODING/LIBC/0.6/src/emx/src/lib/sys/b_ioFileControl.c(334):
014759df 01 04 0004 ErrL 0000: ret -EINVAL - Invalid offStart=2b4 cbRange=7fffffffffffffff
014759df 01 03 0004 ErrL 0000 __libc_Back_ioFileControlStandard (0 ms): D:/CODING/LIBC/0.6/src/emx/src/lib/sys/b_ioFileControl.c(178):

i guess this libc check is wrong:

if (    offStart < 0
      ||  cbRange + offStart < 0)
      LIBCLOG_ERROR_RETURN_MSG(-EINVAL, "ret -EINVAL - Invalid offStart=%llx cbRange=%llx\n", offStart, cbRange);

in the case that cbRange is OFF_MAX the check should also succeed.

Change History (5)

comment:1 by Silvan Scherrer, 11 years ago

Milestone: libc-0.6.6

comment:2 by Silvan Scherrer, 11 years ago

if (offStart < 0
      ||  (cbRange != OFF_MAX && cbRange + offStart < 0))

the above should fix the error

comment:3 by Silvan Scherrer, 11 years ago

Owner: set to Silvan Scherrer
Status: newaccepted

comment:4 by Silvan Scherrer, 11 years ago

Component: baselayoutlibc

comment:5 by bird, 11 years ago

Resolution: fixed
Status: acceptedclosed

Thanks tracking this one down. Fixed in r3844.

Note: See TracTickets for help on using tickets.