Opened 5 years ago

Closed 5 years ago

#273 closed defect (fixed)

fcntl() fails

Reported by: diver Owned by: diver
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 Changed 5 years ago by diver

  • Milestone set to libc-0.6.6

comment:2 Changed 5 years ago by diver

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

the above should fix the error

comment:3 Changed 5 years ago by diver

  • Owner set to diver
  • Status changed from new to accepted

comment:4 Changed 5 years ago by diver

  • Component changed from baselayout to libc

comment:5 Changed 5 years ago by bird

  • Resolution set to fixed
  • Status changed from accepted to closed

Thanks tracking this one down. Fixed in r3844.

Note: See TracTickets for help on using tickets.