]> sourceware.org Git - newlib-cygwin.git/commit
Cygwin: execve: fix setting O_APPEND file offset for native child
authorCorinna Vinschen <corinna@vinschen.de>
Sat, 9 Feb 2019 14:36:02 +0000 (15:36 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Sat, 9 Feb 2019 14:36:02 +0000 (15:36 +0100)
commit0be0b8f0335ec0fad6188b3570dffeba4ec94fea
tree072c575435d3825941dbdd10b45c0b542fcd62f2
parent7816cf363689a65f6618a57a8190cea0e97efa40
Cygwin: execve: fix setting O_APPEND file offset for native child

dtable::set_file_pointers_for_exec is called from
child_info_spawn::worker to move the file position of O_APPEND
files to EOF if the child is a native child.

However, this only works correctly for the first O_APPEND
file descriptor:

- set_file_pointers_for_exec calls SetFilePointer.  The higher
  4 bytes of the desired file offset are given to SetFilePointer
  as pointer to a DWORD value.  On return, SetFilePointer returns
  the higher 4 bytes of the new file position in this DWORD.

- So for the second and subsequent descriptors the higher 4 byte
  of the file position depend on what the actual file position
  of the previous file has been set to:

- If the file is > 2 Gigs, the high offset will not be 0 anymore.

- If the desciptor points to a non-seekable file (i.e., a pipe
  or socket), SetFilePosition returns an error and sets the high
  position to -1.

Fix this by calling SetFilePointerEx instead, which does not
modify the incoming position value.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/dtable.cc
winsup/cygwin/release/3.0
This page took 0.029112 seconds and 5 git commands to generate.