From: Ferry Huberts Date: Tue, 23 Oct 2012 07:51:21 +0000 (+0200) Subject: secure: use sizeof() of the fields being copied X-Git-Tag: v0.6.5~158 X-Git-Url: http://olsr.org/git/?p=olsrd.git;a=commitdiff_plain;h=2db654b6f74f6bc50b03f2ccfa5b77b57b7d9e50 secure: use sizeof() of the fields being copied Signed-off-by: Ferry Huberts --- diff --git a/lib/secure/src/olsrd_secure.c b/lib/secure/src/olsrd_secure.c index 2232f142..e5d15473 100644 --- a/lib/secure/src/olsrd_secure.c +++ b/lib/secure/src/olsrd_secure.c @@ -1009,12 +1009,12 @@ send_rres(struct interface *olsr_if, union olsr_ip_addr *to, union olsr_ip_addr uint8_t checksum_cache[1512 + KEYLENGTH]; /* Create packet + key cache */ /* First the OLSR packet + signature message - digest */ - memcpy(checksum_cache, &rrmsg, sizeof(struct r_respmsg) - SIGNATURE_SIZE); + memcpy(checksum_cache, &rrmsg, sizeof(rrmsg) - sizeof(rrmsg.signature)); /* Then the key */ - memcpy(&checksum_cache[sizeof(struct r_respmsg) - SIGNATURE_SIZE], aes_key, KEYLENGTH); + memcpy(&checksum_cache[sizeof(rrmsg) - sizeof(rrmsg.signature)], aes_key, KEYLENGTH); /* Create the hash */ - CHECKSUM(checksum_cache, (sizeof(struct r_respmsg) - SIGNATURE_SIZE) + KEYLENGTH, rrmsg.signature); + CHECKSUM(checksum_cache, (sizeof(rrmsg) - sizeof(rrmsg.signature)) + KEYLENGTH, rrmsg.signature); } olsr_printf(3, "[ENC]Sending response response to %s\n", olsr_ip_to_string(&buf, to));