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.

svn:r17263
This commit is contained in:
Nick Mathewson 2008-11-12 14:49:17 +00:00
parent ec9690b0f8
commit 6694a86033
3 changed files with 4 additions and 2 deletions

View File

@ -48,6 +48,8 @@ Changes in version 0.2.0.32 - 2008-??-??
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

View File

@ -966,7 +966,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);

View File

@ -157,7 +157,7 @@ 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);
set_uint16(hdr_out, htons(cell->circ_id));
*(uint8_t*)(hdr_out+2) = cell->command;
set_uint16(hdr_out+3, htons(cell->payload_len));
}