Cygwin: fix memory corruption/SEGV if certain socket functions fail

Regression introduced with 2.11.0:

The failure paths in socket, socketpair and accept4 functions and
methods accidentally release *unused* cygheap_fdmanip objects.  The
subsequently called dtable::release method was designed to be called for
*used* cygheap_fdmanip objects only.  Using them on unused objects leads
to NULL pointer member dereferencing.

Worse, the inet/local accept4 methods only release the cygheap_fdmanip
object but neglect to delete the just created fhandler_socket_* object.

Fix this by removing the erroneous release calls in the aforementioned
failure paths and delete the fhandler_socket_* object in accept4 instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2018-10-29 16:12:54 +01:00
parent af85fdd73f
commit 2bbe8697d8
5 changed files with 8 additions and 14 deletions

View File

@@ -14,3 +14,7 @@ Bug Fixes
- Fix a memory corruption when using pipes or FIFOs
Addresses: https://cygwin.com/ml/cygwin-patches/2018-q4/msg00000.html
- Fix potential memory corruption and SEGV if socket(2), socketpair(2),
accept(2), or accept4(2) fail.
Addresses: https://cygwin.com/ml/cygwin/2018-10/msg00229.html