summaryrefslogtreecommitdiff
path: root/win32/win32sck.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32sck.c')
-rw-r--r--win32/win32sck.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/win32/win32sck.c b/win32/win32sck.c
index 2795104b34..8656c0bd67 100644
--- a/win32/win32sck.c
+++ b/win32/win32sck.c
@@ -666,15 +666,19 @@ int
win32_ioctl(int i, unsigned int u, char *data)
{
dTHX;
- u_long argp = (u_long)data;
+ u_long u_long_arg;
int retval;
-
+
if (!wsock_started) {
Perl_croak_nocontext("ioctl implemented only on sockets");
/* NOTREACHED */
}
- retval = ioctlsocket(TO_SOCKET(i), (long)u, &argp);
+ /* mauke says using memcpy avoids alignment issues */
+ memcpy(&u_long_arg, data, sizeof u_long_arg);
+ retval = ioctlsocket(TO_SOCKET(i), (long)u, &u_long_arg);
+ memcpy(data, &u_long_arg, sizeof u_long_arg);
+
if (retval == SOCKET_ERROR) {
if (WSAGetLastError() == WSAENOTSOCK) {
Perl_croak_nocontext("ioctl implemented only on sockets");