Repository : ssh://git@open-mesh.org/alfred
On branches: ecsv/master,master
commit 0c8f7107ce339e34131eee57041e94d6ef985b64 Author: Sven Eckelmann sven@narfation.org Date: Tue Oct 24 10:04:07 2017 +0200
alfred: Remove announce length validation
The announce message has no extra fields. The check whether the header.length field is >= 0 will therefore always be true because header.length is an unsigned short.
Signed-off-by: Sven Eckelmann sven@narfation.org
0c8f7107ce339e34131eee57041e94d6ef985b64 alfred.h | 2 ++ recv.c | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/alfred.h b/alfred.h index 460f52f..f52e66b 100644 --- a/alfred.h +++ b/alfred.h @@ -147,6 +147,8 @@ struct globals { #define debugMalloc(size, num) malloc(size) #define debugFree(ptr, num) free(ptr)
+#define BUILD_BUG_ON(e) ((void)sizeof(char[1 - 2 * !!(e)])) + #define MAX_PAYLOAD ((1 << 16) - 1 - sizeof(struct udphdr))
extern alfred_addr alfred_mcast; diff --git a/recv.c b/recv.c index e897e3d..83fbff9 100644 --- a/recv.c +++ b/recv.c @@ -270,9 +270,6 @@ process_alfred_announce_master(struct globals *globals, struct server *server; struct ether_addr mac; int ret; - int len; - - len = ntohs(announce->header.length);
if (globals->ipv4mode) ret = ipv4_to_mac(interface, source, &mac); @@ -284,8 +281,8 @@ process_alfred_announce_master(struct globals *globals, if (announce->header.version != ALFRED_VERSION) return -1;
- if (len < (sizeof(*announce) - sizeof(announce->header))) - return -1; + /* skip header.length check because "announce" has no extra fields */ + BUILD_BUG_ON(sizeof(*announce) - sizeof(announce->header) != 0);
server = hash_find(interface->server_hash, &mac); if (!server) {