secure: do not hard-code a sizeof()
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 23 Oct 2012 08:05:46 +0000 (10:05 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 23 Oct 2012 08:52:48 +0000 (10:52 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/secure/src/olsrd_secure.c

index 4b040c3..1099519 100644 (file)
@@ -558,12 +558,12 @@ send_challenge(struct interface *olsr_if, const union olsr_ip_addr *new_host)
     uint8_t checksum_cache[1512 + KEYLENGTH];
     /* Create packet + key cache */
     /* First the OLSR packet + signature message - digest */
-    memcpy(checksum_cache, &cmsg, sizeof(struct challengemsg) - SIGNATURE_SIZE);
+    memcpy(checksum_cache, &cmsg, sizeof(cmsg) - sizeof(cmsg.signature));
     /* Then the key */
-    memcpy(&checksum_cache[sizeof(struct challengemsg) - SIGNATURE_SIZE], aes_key, KEYLENGTH);
+    memcpy(&checksum_cache[sizeof(cmsg) - sizeof(cmsg.signature)], aes_key, KEYLENGTH);
 
     /* Create the hash */
-    CHECKSUM(checksum_cache, (sizeof(struct challengemsg) - SIGNATURE_SIZE) + KEYLENGTH, cmsg.signature);
+    CHECKSUM(checksum_cache, (sizeof(cmsg) - sizeof(cmsg.signature)) + KEYLENGTH, cmsg.signature);
   }
   olsr_printf(3, "[ENC]Sending timestamp request to %s challenge 0x%x\n",
              olsr_ip_to_string(&buf, new_host), challenge);