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;
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);
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);
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);
}
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);
}
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)