summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
Diffstat (limited to 'src/or')
-rw-r--r--src/or/buffers.c4
-rw-r--r--src/or/circuitbuild.c6
-rw-r--r--src/or/connection_or.c4
-rw-r--r--src/or/geoip.c1
4 files changed, 9 insertions, 6 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index e8422637cd..09ccb7cb0d 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -1498,8 +1498,8 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
return -1;
}
- req->port = ntohs(*(uint16_t*)(buf->head->data+2));
- destip = ntohl(*(uint32_t*)(buf->head->data+4));
+ req->port = ntohs(get_uint16(buf->head->data+2));
+ destip = ntohl(get_uint32(buf->head->data+4));
if ((!req->port && req->command!=SOCKS_COMMAND_RESOLVE) || !destip) {
log_warn(LD_APP,"socks4: Port or DestIP is zero. Rejecting.");
return -1;
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index ef1bab3206..14b0fb9f1f 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -2308,8 +2308,8 @@ onionskin_answer(or_circuit_t *circ, uint8_t cell_type, const char *payload,
cell_type == CELL_CREATED ? ONIONSKIN_REPLY_LEN : DIGEST_LEN*2);
log_debug(LD_CIRC,"init digest forward 0x%.8x, backward 0x%.8x.",
- (unsigned int)*(uint32_t*)(keys),
- (unsigned int)*(uint32_t*)(keys+20));
+ (unsigned int)get_uint32(keys),
+ (unsigned int)get_uint32(keys+20));
if (circuit_init_cpath_crypto(tmp_cpath, keys, 0)<0) {
log_warn(LD_BUG,"Circuit initialization failed");
tor_free(tmp_cpath);
@@ -2448,6 +2448,8 @@ router_handles_some_port(routerinfo_t *router, smartlist_t *needed_ports)
for (i = 0; i < smartlist_len(needed_ports); ++i) {
addr_policy_result_t r;
+ /* alignment issues aren't a worry for this dereference, since
+ needed_ports is explicitly a smartlist of uint16_t's */
port = *(uint16_t *)smartlist_get(needed_ports, i);
tor_assert(port);
r = compare_addr_to_addr_policy(0, port, router->exit_policy);
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 58e8ec7e7e..6b648b124d 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -147,7 +147,7 @@ void
cell_pack(packed_cell_t *dst, const cell_t *src)
{
char *dest = dst->body;
- *(uint16_t*)dest = htons(src->circ_id);
+ set_uint16(dest, htons(src->circ_id));
*(uint8_t*)(dest+2) = src->command;
memcpy(dest+3, src->payload, CELL_PAYLOAD_SIZE);
}
@@ -158,7 +158,7 @@ cell_pack(packed_cell_t *dst, const cell_t *src)
static void
cell_unpack(cell_t *dest, const char *src)
{
- dest->circ_id = ntohs(*(uint16_t*)(src));
+ dest->circ_id = ntohs(get_uint16(src));
dest->command = *(uint8_t*)(src+2);
memcpy(dest->payload, src+3, CELL_PAYLOAD_SIZE);
}
diff --git a/src/or/geoip.c b/src/or/geoip.c
index d9c8a01519..7f1052e98d 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -145,6 +145,7 @@ _geoip_compare_entries(const void **_a, const void **_b)
static int
_geoip_compare_key_to_entry(const void *_key, const void **_member)
{
+ /* No alignment issue here, since _key really is a pointer to uint32_t */
const uint32_t addr = *(uint32_t *)_key;
const geoip_entry_t *entry = *_member;
if (addr < entry->ip_low)