summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2014-01-13 16:20:00 +1100
committerTony Cook <tony@develop-help.com>2014-01-15 09:37:26 +1100
commite122534c08d52962b50cef019dffa861efbfb801 (patch)
treea149a9fb9ab6bdb305d338dd13a7e561adc8fa53 /pp_sys.c
parent171b35b00178c63555d0095adc2f2e6a72b3d772 (diff)
downloadperl-e122534c08d52962b50cef019dffa861efbfb801.tar.gz
[perl #118843] work around recv() behaviour on cygwin
cygwin inherits recv behaviour from the Win32 sockets API which doesn't modify the namebuf or it's associated size when you recv() from a connected socket, handle this the same way Win32 does by zeroing the length if it's the same as before calling recv(). Also adds some basic socket function tests to the core tests.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 3cd542c72f..3ec7dbe646 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1711,6 +1711,14 @@ PP(pp_sysread)
if (!(IoFLAGS(io) & IOf_UNTAINT))
SvTAINTED_on(bufsv);
SP = ORIGMARK;
+#if defined(__CYGWIN__)
+ /* recvfrom() on cygwin doesn't set bufsize at all for
+ connected sockets, leaving us with trash in the returned
+ name, so use the same test as the Win32 code to check if it
+ wasn't set, and set it [perl #118843] */
+ if (bufsize == sizeof namebuf)
+ bufsize = 0;
+#endif
sv_setpvn(TARG, namebuf, bufsize);
PUSHs(TARG);
RETURN;