diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-11-12 14:41:44 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-11-12 14:41:44 +0000 |
commit | c36ddcbabf60df9f26ece0777766defd7fee751f (patch) | |
tree | 0ec657cbb0b90a629b417a5379f77372a230d8bb /src | |
parent | a790a13705e9d838a4092435ed981179054c6beb (diff) | |
download | tor-c36ddcbabf60df9f26ece0777766defd7fee751f.tar.gz tor-c36ddcbabf60df9f26ece0777766defd7fee751f.zip |
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.
svn:r17262
Diffstat (limited to 'src')
-rw-r--r-- | src/or/buffers.c | 4 | ||||
-rw-r--r-- | src/or/connection_or.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index ba70e555dc..cb36a523e2 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -1010,7 +1010,7 @@ fetch_var_cell_from_buf(buf_t *buf, var_cell_t **out, int linkproto) 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 @@ fetch_var_cell_from_buf(buf_t *buf, var_cell_t **out, int linkproto) 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); diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 5797e5ea16..40dab3e4f0 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -157,8 +157,8 @@ cell_unpack(cell_t *dest, const char *src) 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)); } |