]> sourceware.org Git - glibc.git/commitdiff
Fix aliasing issues in RPC code
authorUlrich Drepper <drepper@gmail.com>
Sun, 4 Dec 2011 18:20:06 +0000 (13:20 -0500)
committerUlrich Drepper <drepper@gmail.com>
Sun, 4 Dec 2011 18:20:06 +0000 (13:20 -0500)
ChangeLog
sunrpc/clnt_tcp.c
sunrpc/clnt_udp.c
sunrpc/clnt_unix.c

index ad891bedd31a6cc39cbf0a360e18d1196f4c48f4..6416f9e75b491af0d55e4349e7e81f1518cb7d9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-04  Ulrich Drepper  <drepper@gmail.com>
+
+       * sunrpc/clnt_unix.c (clntunix_control): Fix aliasing issues.
+       * sunrpc/clnt_tcp.c (clnttcp_control): Likewise.
+       * sunrpc/clnt_udp.c (clntudp_call): Likewise.
+
 2011-12-03  Ulrich Drepper  <drepper@gmail.com>
 
        * inet/netinet/in.h: Provide versions of IN6_IS_ADDR_UNSPECIFIED,
index 7cfbe9e8ddd83b64f8b33fed7df4a6fb2a3b24aa..d1fc43dbfdb0f387fbb4c0321c50d4fbcdfba661 100644 (file)
@@ -364,6 +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;
 
 
   switch (request)
@@ -393,11 +395,24 @@ 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 (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 clnttcp_call() increments once */
       break;
     case CLGET_VERS:
index babee9abfde8e30ae7e7697c90a8afb572f45e4e..294e13a58cf1c62585d0375c74d68da43e635e4e 100644 (file)
@@ -473,8 +473,7 @@ send_again:
       /* see if reply transaction id matches sent id.
        Don't do this if we only wait for a replay */
       if (xargs != NULL
-         && (*((u_int32_t *) (cu->cu_inbuf))
-             != *((u_int32_t *) (cu->cu_outbuf))))
+         && memcmp (cu->cu_inbuf, cu->cu_outbuf, sizeof (u_int32_t)) != 0)
        continue;
       /* we now assume we have the proper reply */
       break;
index 62dc8c604bddec6c4f070d453289df4abc783629..282127bb8b01a87b87b81f0773c4e3aadbce0dfc 100644 (file)
@@ -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:
This page took 0.056392 seconds and 5 git commands to generate.