Commit Graph

19362 Commits

Author SHA1 Message Date
Corinna Vinschen 5216ec9458 Cygwin: fix buffer overrun in cygwin_strcasecmp
sys_mbstowcs is called with the destination buffer length
set to MaximumLength from the receiving UNICODE_STRING buffer.
This is twice as much as the actual size of the buffer in
wchar_t units, which is the unit expected by sys_mbstowcs.

sys_mbstowcs always attaches a NUL, within the destination
buffersize given.  But if the string is exactly one wchar_t
less than the actual buffer, and the buffersize is given too
large, sys_mbstowcs writes a NUL one wchar_t beyond the buffer.

This has only been exposed with Cygwin 3.1.5 because alloca
on newer gcc 9 apparently allocates more tightly.  The alloca
buffer here is requested with 16 bytes, which is exactly the
number of bytes required for the string L"cmd.exe".  Older gcc
apparently allocated a few more bytes on the stack, while gcc 9
allocates in 16 byte granularity...

Fix this by giving the correct destination buffer size to
sys_mbstowcs.

Fixes: https://cygwin.com/pipermail/cygwin/2020-June/245226.html
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:22 -04:00
Corinna Vinschen 1d0b1e9bd5 libm: machine: Add missing sparc and mips configuration
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:22 -04:00
Eshan dhawan via Newlib 011d459484 mips fenv support
Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>
2020-10-14 10:54:22 -04:00
Eshan dhawan via Newlib 09f5b05014 SPARC fenv support
Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>
2020-10-14 10:54:22 -04:00
Eshan dhawan via Newlib 9fc5eb7747 fenv aarch64 support
Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>
2020-10-14 10:54:22 -04:00
Dimitar Dimitrov a5cd471c7c pru: Fix memory corruption on syscall return
In the initial code I missed one level of pointer indirection. Instead
of storing errno in impure_data, _impure_ptr was corrupted.

Only simulator is impacted. Real targets have no OS and no syscalls.

This resolves a bunch of stdio cases from the GCC testsuite:
  FAIL->PASS: gcc.c-torture/execute/printf-2.c   -O0  execution test

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2020-10-14 10:54:22 -04:00
Corinna Vinschen 26338189a8 Cygwin: add new IPPROTO_TCP options to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:22 -04:00
Corinna Vinschen fd4b5bd9b2 Cygwin: tcp: Support TCP_QUICKACK
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:22 -04:00
Corinna Vinschen 48656e7834 Cygwin: tcp: Support TCP_USER_TIMEOUT
Use TCP_MAXRTMS on newer systems, TCP_MAXRT on older systems.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:21 -04:00
Corinna Vinschen 140029a099 Cygwin: tcp: Support TCP_KEEPIDLE, TCP_KEEPCNT, TCP_KEEPINTVL
Use WSAIoctl(SIO_KEEPALIVE_VALS) on older systems.

Make sure that keep-alive timeout is equivalent to
TCP_KEEPIDLE + TCP_KEEPCNT * TCP_KEEPINTVL on older systems,
even with TCP_KEEPCNT being a fixed value on those systems.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:21 -04:00
Corinna Vinschen 1acd185bea Cygwin: tcp: Support TCP_FASTOPEN
TCP_FASTOPEN is supported since W10 1607.  Fake otherwise.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:21 -04:00
Corinna Vinschen 310ab6345e Cygwin: tcp: fix IPPROTO_TCP option handling
- Drop definitions from <cygwin/sockets.h>
- Drop options only available on BSD
- Fix value of TCP_MAXSEG.  It was still defined as the BSD value
  while WinSock uses another value
- Handle the fact that TCP_MAXSEG is a R/O value in WinSock

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:21 -04:00
Takashi Yano via Cygwin-patches 2f5bd00569 Cygwin: pty, termios: Unify thoughts of read ahead beffer handling.
- Return value of eat_readahead() is redefined. The return values
  of fhandler_termios::eat_readahead() and fhandler_pty_slave::
  eat_readahead() were little bit different. This patch unifies
  them to number of bytes eaten by eat_readahead().
- Considerration for raixget() is added to fhandler_pty_master::
  accept_input() code.
- Transfering contents of read ahead buffer in
  fhandler_pty_master::transfer_input_to_pcon() is removed since
  it is not necessary.
- fhandler_pty_slave::eat_readahead() ckecks EOL only when ICANON
  is set.
- Guard for _POSIX_VDISABLE is added in checking EOL.
2020-10-14 10:54:21 -04:00
Takashi Yano via Cygwin-patches c42fd9415f Cygwin: pty: Discard CSI > Pm m sequence from native windows apps.
- If vim is started from WSL (Ubuntu) which is executed in pseudo
  console in mintty, shift key and ctrl key do not work. Though
  this issue is similar to the issue resolved by commit
  4527541ec6, that commit is not
  effective for this issue. This patch fixes the issue by discarding
  "CSI > Pm m" in fhandler_pty_master::pty_master_fwd_thread().
2020-10-14 10:54:21 -04:00
Eshan dhawan via Newlib c5bb4fc899 fenv support arm
Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>
2020-10-14 10:54:21 -04:00
Jeff Johnston db57a46672 Regenerate libm/machine configuration files for powerpc 2020-10-14 10:54:21 -04:00
Takashi Yano via Cygwin-patches 93d5b64449 Cygwin: pty: Fix screen distortion after less for native apps again.
- Commit c4b060e3fe seems to be not
  enough. Moreover, it does not work as expected at all in Win10
  1809. This patch essentially reverts that commit and add another
  fix. After all, the cause of the problem was a race issue in
  switch_to_pcon_out flag. That is, this flag is set when native
  app starts, however, it is delayed by wait_pcon_fwd(). Since the
  flag is not set yet when less starts, the data which should go
  into the output_handle accidentally goes into output_handle_cyg.
  This patch fixes the problem more essentially for the cause of
  the problem than previous one.
2020-10-14 10:54:21 -04:00
Eshan dhawan via Newlib 3ef3750910 hard float support for PowerPC taken from FreeBSD
Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>
2020-10-14 10:54:21 -04:00
Corinna Vinschen a4327f2576 Bump version to 3.1.6
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:21 -04:00
Takashi Yano via Cygwin-patches c4244a0200 Cygwin: pty: Fix screen distortion after using less for native apps.
- If the output of non-cygwin apps is browsed using less, screen is
  ocasionally distorted after less exits. This frequently happens
  if cmd.exe is executed after less. This patch fixes the issue.
2020-10-14 10:54:21 -04:00
Takashi Yano via Cygwin-patches 87d8065bdb Cygwin: pty: Revise the code which prevents undesired window title.
- In current pty, the window title can not be set from non-cygwin
  program due to the code which prevents overwriting the window
  title to "cygwin-console-helper.exe" in fhandler_pty_master::pty_
  master_fwd_thread(). This patch fixes the issue.
2020-10-14 10:54:21 -04:00
Takashi Yano via Cygwin-patches 3be69c5100 Cygwin: pty: Clean up fhandler_pty_master::pty_master_fwd_thread().
- Remove the code which is not necessary anymore.
2020-10-14 10:54:21 -04:00
Takashi Yano via Cygwin-patches a615ec9d49 Cygwin: console: Discard some unsupported escape sequences.
- If the cygwin vim is started from a non-cygwin process which is
  executed in pseudo console, shift key and ctrl key do not work.
  In this case, vim is executed under /dev/cons*. If vim outputs
  escape sequence which is not supported by pseudo console, the
  escape sequence is leaked into the parent pty. This causes
  unexpected results. This patch fixes the issue by discarding
  "CSI > Pm m". "OSC 10;? BEL/ST" and "OSC 11;? BEL/ST" are
  discarded as well.
2020-10-14 10:54:21 -04:00
Takashi Yano via Cygwin-patches 32edd9570d Cygwin: pty: Prevent garbage remained in read ahead buffer.
- After commit 29431fcb5b, the issue
  reported in https://cygwin.com/pipermail/cygwin/2020-May/245057.html
  occurs. This is caused by the following mechanism. Cygwin less
  called from non-cygwin git is executed under /dev/cons* rather
  than /dev/pty* because parent git process only inherits pseudo
  console handle. Therefore, less sets ICANON flag for /dev/cons*
  rather than original /dev/pty*. When pty is switched to non-cygwin
  git process, line_edit() is used in fhandler_pty_master::write()
  only to set input_available_event and read ahead buffer is supposed
  to be flushed in accept_input(). However, ICANON flag is not set
  for /dev/pty*, so accept_input() is not called unless newline
  is entered. As a result, the input data remains in the read ahead
  buffer. This patch fixes the issue.
2020-10-14 10:54:21 -04:00
Corinna Vinschen 1b5fb1f5bc Cygwin: update C++ dialect to gnu++14
Disable -std option since gnu++14 is default anyway, but keep
it available as comment.

Update dynamic exception specifications deprecated with
C++11 to C++11-introduced noexcept expression.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:21 -04:00
Takashi Yano via Cygwin-patches eec0f19adb Cygwin: console: Make cursor keys work in vim under ConEmu.
- After commit 774b8996d1, cursor
  keys do not work in vim under ConEmu without cygwin-connector.
  This patch fixes the issue.
2020-10-14 10:54:20 -04:00
Ken Brown a2627c34dc Cygwin: stat: fix st_mode of fifos again
This partially reverts commit
f36262d56a.  That commit incorrectly
made the st_mode of a fifo reflect the Windows permissions of the disk
file underlying the fifo.
2020-10-14 10:54:20 -04:00
Takashi Yano via Cygwin-patches 896f6dc387 Cygwin: pty: Prevent meaningless ResizePseudoConsole() calls.
- This patch prevents to call ResizePseudoConsole() unless the pty
  is resized.
2020-10-14 10:54:20 -04:00
Takashi Yano via Cygwin-patches fe59ac0da7 Cygwin: pty: Fix a bug in free_attached_console().
- After commit 7659ff0f5a, nohup does
  not work as expected. This patch fixes the issue.

  Addresses:
  https://cygwin.com/pipermail/cygwin-developers/2020-May/011885.html
2020-10-14 10:54:20 -04:00
Corinna Vinschen 1a39a29d10 Cygwin: FAQ: fix Cygwin build requirements
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:20 -04:00
Corinna Vinschen e74f0a9847 Cygwin: drop useless comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:20 -04:00
Corinna Vinschen 21ea73be21 Cygwin: add missing files to 'clean' build rule
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:20 -04:00
Corinna Vinschen 077f6310ca Cygwin: revamp localtime.o build rule
Rename localtime.c.patched to localtime.patched.c to keep the correct
language suffix.

Create localtime.patched.c in the build dir rather than in the source
dir.  Decouple the build rule for creating localtime.patched.c from
the rule to build localtime.o, so we don't have to rebuild the patched
source file all the time.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:20 -04:00
Corinna Vinschen 28aa678491 Cygwin: convert localtime_wrapper.c to plain C source
That also requires a small tweak to localtime.c.patch, otherwise
GCC complains about the position of the 'trydefrules' label.
Also, simplify includes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:20 -04:00
Corinna Vinschen 944691f0ba Cygwin: rename localtime.cc to localtime_wrapper.c
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:20 -04:00
Corinna Vinschen 28099273a0 Cygwin: move localtime.o build rule to end of file
otherwise a simple `make' in the cygwin dir won't build
the DLL anymore.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:20 -04:00
Mark Geisert a6c36e0458 Cygwin: tzcode resync: details
Add tz_posixrules.h with data generated from most recent Cygwin tzdata
package.  Establish localtime.cc as primarily a wrapper around a patched
copy of localtime.c.  See README for more information.
2020-10-14 10:54:20 -04:00
Mark Geisert 27b6aea3f6 Cygwin: tzcode resync: imports
Import most recent NetBSD localtime.c, private.h, and tzfile.h.  An
empty namespace.h suffices for Cygwin.
2020-10-14 10:54:20 -04:00
Mark Geisert ae0dc2f685 Cygwin: tzcode resync: basics
Modifies winsup/cygwin/Makefile.in to build localtime.o from items in
new winsup/cygwin/tzcode subdirectory.  Compiler option "-fpermissive"
is used to accept warnings about missing casts on the return values of
malloc() calls.  This patch also removes existing localtime.cc and
tz_posixrules.h from winsup/cygwin as they are superseded by the
subsequent patches in this set.
2020-10-14 10:54:20 -04:00
Corinna Vinschen 07d45ec871 Cygwin: fix declaration of __small_{v}sprintf
Both functions are declared as extern "C" functions in
sys/smallprint.h, but as C++ funcs in winsup.h and in the
source itself.

Add extern "C to definitions, remove declarations in winsup.h
and include sys/smallprint.h instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:20 -04:00
Takashi Yano via Cygwin-patches 2972b2eebf Cygwin: pty: Stop counting number of slaves attached to pseudo console.
- The number of slaves attached to pseudo console is used only for
  triggering redraw screen. Counting was not only needless, but also
  did not work as expected. This patch removes the code for counting.
2020-10-14 10:54:20 -04:00
Takashi Yano via Cygwin-patches 2afa2b7469 Cygwin: pty: Revise code to make system_printf() work after close.
- After commit 0365031ce1, the issue
  https://cygwin.com/pipermail/cygwin-patches/2020q2/010259.html
  occurs. This patch fixes the issue.
2020-10-14 10:54:20 -04:00
Ken Brown a457159ee5 Cygwin: FIFO: add missing unlock
There was a missing call to reader_opening_unlock on one of the error
exits in fhandler_fifo::open.
2020-10-14 10:54:20 -04:00
Ken Brown 5deb76efde Cygwin: FIFO: Revert "take ownership on exec"
This reverts commit 39a9cd9465.

There is no need to explicitly take ownership in fixup_after_exec; if
ownership transfer is needed, it will be taken care of by
fhandler_fifo::close when the parent closes.  Moreover, closing the
parent's fifo_reader_thread can cause problems, such as the one
reported here:

  https://cygwin.com/pipermail/cygwin-patches/2020q2/010235.html
2020-10-14 10:54:20 -04:00
Takashi Yano via Cygwin-patches 55c163dce0 Cygwin: pty: Make system_printf() work after closing pty slave.
- Current pty cannot show system_printf() output after closing pty
  slave. This patch fixes the issue.
2020-10-14 10:54:20 -04:00
Takashi Yano via Cygwin-patches 42196698ca Cygwin: pty: Call FreeConsole() only if attached to current pty.
- After commit 071b8e0cbd, the problem
  reported in https://cygwin.com/pipermail/cygwin/2020-May/244873.html
  occurs. This is due to freeing console device accidentally rather
  than pseudo console. This patch makes sure to call FreeConsole()
  only if the process is attached to the pseudo console of the current
  pty.
2020-10-14 10:54:19 -04:00
Szabolcs Nagy e7b7406d67 Reimplement aligned_alloc
The original implementation had multiple issues:

- Only worked when posix_memalign was available (Linux, RTEMS).
- Violated C11 link namespace rules by calling posix_memalign.
- Failed to set errno on error.

These can be fixed by essentially using the same implementation
for aligned_alloc as for memalign, i.e. simply calling _memalign_r
(which is always available and a "more reserved name" although
technically still not in the reserved link namespace, at least
code written in c cannot define a colliding symbol, newlib has
plenty such namespace issues so this is fine).

It is not clear what the right policy is when MALLOC_PROVIDED is set,
currently that does not cover aligned_alloc so it is kept that way.

Tested on aarch64-none-elf
2020-10-14 10:54:19 -04:00
Takashi Yano via Cygwin-patches a741aadfc5 Cygwin: termios: Set ECHOE, ECHOK, ECHOCTL and ECHOKE by default.
- Backspace key does not work correctly in linux session opend by
  ssh from cygwin console if the shell is bash. This is due to lack
  of these flags.

  Addresses: https://cygwin.com/pipermail/cygwin/2020-May/244837.html.
2020-10-14 10:54:19 -04:00
David Macek via Cygwin-patches 85a0326df2 cygwin: doc: Add keywords for ACE order issues
Windows Explorer shows a warning with Cygwin-created DACLs, but putting
the text of the warning into Google doesn't lead to the relevant Cygwin
docs.  Let's copy the warning text into the docs in the hopes of helping
confused users.  Most of the credit for the wording belongs to Yaakov
Selkowitz.

Latest inquiry: <https://cygwin.com/pipermail/cygwin/2020-May/244814.html>

Signed-off-by: David Macek <david.macek.0@gmail.com>
2020-10-14 10:54:19 -04:00
Ken Brown a557b50d73 Cygwin: FIFO: improve the interruptibility of raw_read
During a blocking read, we sleep for 1 ms after each iteration through
the connected writers.  Currently we do this by calling Sleep (1).
Remove this call to Sleep and instead change the timeout in the
cygwait call from 0 to 1, so that raw_read can be interrupted while
sleeping.
2020-10-14 10:54:19 -04:00