summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-11-06 16:58:57 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-11-06 16:58:57 +0100
commitf7483321a25f8ce8e919ff635798db75976a11e5 (patch)
tree3f212d0c8b96fb33130bc0831f0b37150f5a9f63
parenta7b458b257d722000e2b518e4e6141c49f30c761 (diff)
cookie: avoid void pointer arithmatic
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--src/cookie.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cookie.c b/src/cookie.c
index 8d66457..84f9d25 100644
--- a/src/cookie.c
+++ b/src/cookie.c
@@ -94,7 +94,7 @@ enum cookie_mac_state cookie_validate_packet(struct cookie_checker *checker, str
u8 computed_mac[COOKIE_LEN];
u8 cookie[COOKIE_LEN];
enum cookie_mac_state ret;
- struct message_macs *macs = (struct message_macs *)(data_start + data_len - sizeof(struct message_macs));
+ struct message_macs *macs = (struct message_macs *)((u8 *)data_start + data_len - sizeof(struct message_macs));
ret = INVALID_MAC;
down_read(&checker->device->static_identity.lock);
@@ -132,7 +132,7 @@ out:
void cookie_add_mac_to_packet(void *message, size_t len, struct wireguard_peer *peer)
{
- struct message_macs *macs = message + len - sizeof(struct message_macs);
+ struct message_macs *macs = (struct message_macs *)((u8 *)message + len - sizeof(struct message_macs));
down_read(&peer->device->static_identity.lock);
if (unlikely(!peer->device->static_identity.has_identity)) {
@@ -158,7 +158,7 @@ void cookie_add_mac_to_packet(void *message, size_t len, struct wireguard_peer *
void cookie_message_create(struct message_handshake_cookie *dst, struct sk_buff *skb, void *data_start, size_t data_len, __le32 index, struct cookie_checker *checker)
{
- struct message_macs *macs = (struct message_macs *)(data_start + data_len - sizeof(struct message_macs));
+ struct message_macs *macs = (struct message_macs *)((u8 *)data_start + data_len - sizeof(struct message_macs));
struct blake2s_state state;
u8 key[NOISE_SYMMETRIC_KEY_LEN];
u8 cookie[COOKIE_LEN];