aboutsummaryrefslogtreecommitdiff
path: root/sunrpc/clnt_unix.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-12-04 13:20:06 -0500
committerUlrich Drepper <drepper@gmail.com>2011-12-04 13:20:06 -0500
commit4efbd5cb39dfa170056532185c724ab2ff545585 (patch)
tree6fc2f9183259908f20701503b97f6a6ad2dead40 /sunrpc/clnt_unix.c
parentaff2453df710c872588572a31928cff0e47da5b7 (diff)
downloadglibc-4efbd5cb39dfa170056532185c724ab2ff545585.tar
glibc-4efbd5cb39dfa170056532185c724ab2ff545585.tar.gz
glibc-4efbd5cb39dfa170056532185c724ab2ff545585.tar.bz2
glibc-4efbd5cb39dfa170056532185c724ab2ff545585.zip
Fix aliasing issues in RPC code
Diffstat (limited to 'sunrpc/clnt_unix.c')
-rw-r--r--sunrpc/clnt_unix.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sunrpc/clnt_unix.c b/sunrpc/clnt_unix.c
index 62dc8c604b..282127bb8b 100644
--- a/sunrpc/clnt_unix.c
+++ b/sunrpc/clnt_unix.c
@@ -338,7 +338,8 @@ static bool_t
clntunix_control (CLIENT *cl, int request, char *info)
{
struct ct_data *ct = (struct ct_data *) cl->cl_private;
-
+ u_long *mcall_ptr;
+ u_long ul;
switch (request)
{
@@ -366,11 +367,24 @@ clntunix_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 (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
/* decrement by 1 as clntunix_call() increments once */
break;
case CLGET_VERS: