secure: use sizeof() of the fields being copied
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 23 Oct 2012 07:58:27 +0000 (09:58 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 23 Oct 2012 08:52:48 +0000 (10:52 +0200)
lib/secure/src/olsrd_secure.c

index c865477..b874f5a 100644 (file)
@@ -937,12 +937,12 @@ send_cres(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, &crmsg, sizeof(struct c_respmsg) - SIGNATURE_SIZE);
+    memcpy(checksum_cache, &crmsg, sizeof(crmsg) - sizeof(crmsg.signature));
     /* Then the key */
-    memcpy(&checksum_cache[sizeof(struct c_respmsg) - SIGNATURE_SIZE], aes_key, KEYLENGTH);
+    memcpy(&checksum_cache[sizeof(crmsg) - sizeof(crmsg.signature)], aes_key, KEYLENGTH);
 
     /* Create the hash */
-    CHECKSUM(checksum_cache, (sizeof(struct c_respmsg) - SIGNATURE_SIZE) + KEYLENGTH, crmsg.signature);
+    CHECKSUM(checksum_cache, (sizeof(crmsg) - sizeof(crmsg.signature)) + KEYLENGTH, crmsg.signature);
   }
 
   olsr_printf(3, "[ENC]Sending challenge response to %s challenge 0x%x\n", olsr_ip_to_string(&buf, to), challenge);