diff options
author | Joseph Myers <joseph@codesourcery.com> | 2012-11-09 18:21:59 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2012-11-09 18:21:59 +0000 |
commit | fb1ae1eede65c9b7227d8f3da2e27fd720b8b711 (patch) | |
tree | d1f65cb9773c6ac0121ca7897fcbfd59af969b4a /sunrpc/clnt_tcp.c | |
parent | 554066b83b1a0d14e6e7a24a45ef3f65342aae76 (diff) | |
download | glibc-fb1ae1eede65c9b7227d8f3da2e27fd720b8b711.tar.gz glibc-fb1ae1eede65c9b7227d8f3da2e27fd720b8b711.tar.xz glibc-fb1ae1eede65c9b7227d8f3da2e27fd720b8b711.zip |
Fix sunrpc 64-bit (especially big-endian) issues (bug 14821).
Diffstat (limited to 'sunrpc/clnt_tcp.c')
-rw-r--r-- | sunrpc/clnt_tcp.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/sunrpc/clnt_tcp.c b/sunrpc/clnt_tcp.c index 6bd4c8c0cd..ec85930e44 100644 --- a/sunrpc/clnt_tcp.c +++ b/sunrpc/clnt_tcp.c @@ -364,8 +364,8 @@ static bool_t clnttcp_control (CLIENT *cl, int request, char *info) { struct ct_data *ct = (struct ct_data *) cl->cl_private; - u_long *mcall_ptr; u_long ul; + u_int32_t ui32; switch (request) @@ -395,24 +395,15 @@ clnttcp_control (CLIENT *cl, int request, char *info) * first element in the call structure *. * This will get the xid of the PREVIOUS call */ -#if 0 - /* This original code has aliasing issues. */ - *(u_long *)info = ntohl (*(u_long *)ct->ct_mcall); -#else - mcall_ptr = (u_long *)ct->ct_mcall; - ul = ntohl (*mcall_ptr); + memcpy (&ui32, ct->ct_mcall, sizeof (ui32)); + ul = ntohl (ui32); memcpy (info, &ul, sizeof (ul)); -#endif break; case CLSET_XID: /* This will set the xid of the NEXT call */ -#if 0 - /* This original code has aliasing issues. */ - *(u_long *)ct->ct_mcall = htonl (*(u_long *)info - 1); -#else - ul = ntohl (*(u_long *)info - 1); - memcpy (ct->ct_mcall, &ul, sizeof (ul)); -#endif + memcpy (&ul, info, sizeof (ul)); + ui32 = htonl (ul - 1); + memcpy (ct->ct_mcall, &ui32, sizeof (ui32)); /* decrement by 1 as clnttcp_call() increments once */ break; case CLGET_VERS: @@ -422,12 +413,14 @@ clnttcp_control (CLIENT *cl, int request, char *info) * begining of the RPC header. MUST be changed if the * call_struct is changed */ - *(u_long *)info = ntohl (*(u_long *)(ct->ct_mcall + - 4 * BYTES_PER_XDR_UNIT)); + memcpy (&ui32, ct->ct_mcall + 4 * BYTES_PER_XDR_UNIT, sizeof (ui32)); + ul = ntohl (ui32); + memcpy (info, &ul, sizeof (ul)); break; case CLSET_VERS: - *(u_long *)(ct->ct_mcall + 4 * BYTES_PER_XDR_UNIT) - = htonl (*(u_long *)info); + memcpy (&ul, info, sizeof (ul)); + ui32 = htonl (ul); + memcpy (ct->ct_mcall + 4 * BYTES_PER_XDR_UNIT, &ui32, sizeof (ui32)); break; case CLGET_PROG: /* @@ -436,12 +429,14 @@ clnttcp_control (CLIENT *cl, int request, char *info) * begining of the RPC header. MUST be changed if the * call_struct is changed */ - *(u_long *)info = ntohl(*(u_long *)(ct->ct_mcall + - 3 * BYTES_PER_XDR_UNIT)); + memcpy (&ui32, ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT, sizeof (ui32)); + ul = ntohl (ui32); + memcpy (info, &ul, sizeof (ul)); break; case CLSET_PROG: - *(u_long *)(ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT) - = htonl(*(u_long *)info); + memcpy (&ul, info, sizeof (ul)); + ui32 = htonl (ul); + memcpy (ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT, &ui32, sizeof (ui32)); break; /* The following are only possible with TI-RPC */ case CLGET_RETRY_TIMEOUT: |