From 8599d6325653b0fdcbc68d36d30d571ef23e928e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 16 Nov 2016 14:02:56 +1030 Subject: [PATCH] sphinx: add brackets around constant definition Always do this, otherwise "MACRO * foo" can have unexpected results. Signed-off-by: Rusty Russell --- daemon/sphinx.c | 2 +- daemon/sphinx.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/daemon/sphinx.c b/daemon/sphinx.c index 9ad7fdcbc..f31405a11 100644 --- a/daemon/sphinx.c +++ b/daemon/sphinx.c @@ -12,7 +12,7 @@ #define BLINDING_FACTOR_SIZE 32 #define SHARED_SECRET_SIZE 32 -#define NUM_STREAM_BYTES (2 * NUM_MAX_HOPS + 2) * SECURITY_PARAMETER +#define NUM_STREAM_BYTES ((2 * NUM_MAX_HOPS + 2) * SECURITY_PARAMETER) #define KEY_LEN 32 struct hop_params { diff --git a/daemon/sphinx.h b/daemon/sphinx.h index 0109391a9..d9253b8bc 100644 --- a/daemon/sphinx.h +++ b/daemon/sphinx.h @@ -13,11 +13,11 @@ #define SECURITY_PARAMETER 20 #define NUM_MAX_HOPS 20 #define HOP_PAYLOAD_SIZE 20 -#define TOTAL_HOP_PAYLOAD_SIZE NUM_MAX_HOPS * HOP_PAYLOAD_SIZE +#define TOTAL_HOP_PAYLOAD_SIZE (NUM_MAX_HOPS * HOP_PAYLOAD_SIZE) #define MESSAGE_SIZE 0 -#define ROUTING_INFO_SIZE 2 * NUM_MAX_HOPS * SECURITY_PARAMETER -#define TOTAL_PACKET_SIZE 1 + 33 + SECURITY_PARAMETER + ROUTING_INFO_SIZE + \ - TOTAL_HOP_PAYLOAD_SIZE + MESSAGE_SIZE +#define ROUTING_INFO_SIZE (2 * NUM_MAX_HOPS * SECURITY_PARAMETER) +#define TOTAL_PACKET_SIZE (1 + 33 + SECURITY_PARAMETER + ROUTING_INFO_SIZE + \ + TOTAL_HOP_PAYLOAD_SIZE + MESSAGE_SIZE) struct onionpacket { /* Cleartext information */