From 66f878513f1aa62c14984eddad32c6a3c7b26025 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 20 Mar 2004 09:30:30 +0000 Subject: deal with hardware word alignment this was causing the seg faults on sparc processors i wonder if i got them all. svn:r1314 --- src/or/cpuworker.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/or/cpuworker.c') diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index ba7a0837a..17216cc18 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -48,6 +48,7 @@ static void tag_unpack(char *tag, uint32_t *addr, uint16_t *port, uint16_t *circ } int connection_cpu_process_inbuf(connection_t *conn) { + char success; unsigned char buf[LEN_ONION_RESPONSE]; uint32_t addr; uint16_t port; @@ -77,10 +78,11 @@ int connection_cpu_process_inbuf(connection_t *conn) { return 0; /* not yet */ assert(buf_datalen(conn->inbuf) == LEN_ONION_RESPONSE); - connection_fetch_from_buf(buf,LEN_ONION_RESPONSE,conn); + connection_fetch_from_buf(&success,1,conn); + connection_fetch_from_buf(buf,LEN_ONION_RESPONSE-1,conn); /* parse out the circ it was talking about */ - tag_unpack(buf+1, &addr, &port, &circ_id); + tag_unpack(buf, &addr, &port, &circ_id); circ = NULL; p_conn = connection_exact_get_by_addr_port(addr,port); if(p_conn) @@ -91,12 +93,12 @@ int connection_cpu_process_inbuf(connection_t *conn) { goto done_processing; } assert(circ->p_conn); - if(*buf == 0) { + if(success == 0) { log_fn(LOG_WARN,"decoding onionskin failed. Closing."); circuit_mark_for_close(circ); goto done_processing; } - if(onionskin_answer(circ, buf+1+TAG_LEN, buf+1+TAG_LEN+ONIONSKIN_REPLY_LEN) < 0) { + if(onionskin_answer(circ, buf+TAG_LEN, buf+TAG_LEN+ONIONSKIN_REPLY_LEN) < 0) { log_fn(LOG_WARN,"onionskin_answer failed. Closing."); circuit_mark_for_close(circ); goto done_processing; -- cgit v1.2.3