[or-cvs] r17263: {tor} Backport: Apparently sparc64 is way more strict about uint16 (in tor/branches/tor-0_2_0-patches: . src/or)

nickm at seul.org nickm at seul.org
Wed Nov 12 14:49:18 UTC 2008


Author: nickm
Date: 2008-11-12 09:49:17 -0500 (Wed, 12 Nov 2008)
New Revision: 17263

Modified:
   tor/branches/tor-0_2_0-patches/ChangeLog
   tor/branches/tor-0_2_0-patches/src/or/buffers.c
   tor/branches/tor-0_2_0-patches/src/or/connection_or.c
Log:
Backport: Apparently sparc64 is way more strict about uint16_t access alignment than I had thought: it gave bus errors when messing with var-cell headers.  Maybe this patch will fix bug 862.

Modified: tor/branches/tor-0_2_0-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_2_0-patches/ChangeLog	2008-11-12 14:41:44 UTC (rev 17262)
+++ tor/branches/tor-0_2_0-patches/ChangeLog	2008-11-12 14:49:17 UTC (rev 17263)
@@ -48,6 +48,8 @@
       Bugfix on 0.2.0.x (??).
     - Remove the old v2 directory authority 'lefkada' from the default
       list. It has been gone for many months.
+    - Stop doing unaligned memory access that generated bus errors on
+      sparc64.  Bugfix on 0.2.0.10-alpha.  Fix for bug 862.
 
   o Minor bugfixes (controller):
     - Make DNS resolved events into "CLOSED", not "FAILED". Bugfix on

Modified: tor/branches/tor-0_2_0-patches/src/or/buffers.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/buffers.c	2008-11-12 14:41:44 UTC (rev 17262)
+++ tor/branches/tor-0_2_0-patches/src/or/buffers.c	2008-11-12 14:49:17 UTC (rev 17263)
@@ -966,7 +966,7 @@
     return 1;
   result = var_cell_new(length);
   result->command = command;
-  result->circ_id = ntohs(*(uint16_t*)hdr);
+  result->circ_id = ntohs(get_uint16(hdr));
 
   buf_remove_from_front(buf, VAR_CELL_HEADER_SIZE);
   peek_from_buf(result->payload, length, buf);

Modified: tor/branches/tor-0_2_0-patches/src/or/connection_or.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/connection_or.c	2008-11-12 14:41:44 UTC (rev 17262)
+++ tor/branches/tor-0_2_0-patches/src/or/connection_or.c	2008-11-12 14:49:17 UTC (rev 17263)
@@ -157,7 +157,7 @@
 void
 var_cell_pack_header(const var_cell_t *cell, char *hdr_out)
 {
-  *(uint16_t*)(hdr_out) = htons(cell->circ_id);
+  set_uint16(hdr_out, htons(cell->circ_id));
   *(uint8_t*)(hdr_out+2) = cell->command;
   set_uint16(hdr_out+3, htons(cell->payload_len));
 }



More information about the tor-commits mailing list