[or-cvs] r17262: {tor} Apparently sparc64 is way more strict about uint16_t access (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Wed Nov 12 14:41:45 UTC 2008


Author: nickm
Date: 2008-11-12 09:41:44 -0500 (Wed, 12 Nov 2008)
New Revision: 17262

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/buffers.c
   tor/trunk/src/or/connection_or.c
Log:
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/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-11-12 14:39:25 UTC (rev 17261)
+++ tor/trunk/ChangeLog	2008-11-12 14:41:44 UTC (rev 17262)
@@ -8,6 +8,8 @@
       bug 859.
     - Made Tor a little less aggressive about deleting expired certificates.
       Partial fix for bug 854.
+    - Stop doing unaligned memory access that generated bus errors on
+      sparc64.  Fix for bug 862.
 
   o Minor features (controller):
     - Return circuit purposes in response to GETINFO circuit-status.  Fixes

Modified: tor/trunk/src/or/buffers.c
===================================================================
--- tor/trunk/src/or/buffers.c	2008-11-12 14:39:25 UTC (rev 17261)
+++ tor/trunk/src/or/buffers.c	2008-11-12 14:41:44 UTC (rev 17262)
@@ -1010,7 +1010,7 @@
     return 0;
   peek_from_buf(hdr, sizeof(hdr), buf);
 
-  command = *(uint8_t*)(hdr+2);
+  command = get_uint8(hdr+2);
   if (!(CELL_COMMAND_IS_VAR_LENGTH(command)))
     return 0;
 
@@ -1019,7 +1019,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/trunk/src/or/connection_or.c
===================================================================
--- tor/trunk/src/or/connection_or.c	2008-11-12 14:39:25 UTC (rev 17261)
+++ tor/trunk/src/or/connection_or.c	2008-11-12 14:41:44 UTC (rev 17262)
@@ -157,8 +157,8 @@
 void
 var_cell_pack_header(const var_cell_t *cell, char *hdr_out)
 {
-  *(uint16_t*)(hdr_out) = htons(cell->circ_id);
-  *(uint8_t*)(hdr_out+2) = cell->command;
+  set_uint16(hdr_out, htons(cell->circ_id));
+  set_uint8(hdr_out+2, cell->command);
   set_uint16(hdr_out+3, htons(cell->payload_len));
 }
 



More information about the tor-commits mailing list