From 0699fa590693c6470f2355af1f35092ee4f5be40 Mon Sep 17 00:00:00 2001 From: PgSocks Date: Tue, 27 Dec 2022 19:37:42 -0600 Subject: [PATCH] Fix crc validation --- src/message.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/message.c b/src/message.c index d73fe75..e7c4a39 100644 --- a/src/message.c +++ b/src/message.c @@ -9,7 +9,8 @@ message_validate(const union Message* message) { if(message->header.crc != crc8(message, 3)) return MESSAGEERR_HEADERCRC; - if(message->header.crc != crc16(message, length - sizeof(struct Footer))) + struct Footer* footer = (void*)message + length - sizeof(struct Footer); + if(footer->crc != crc16(message, length - sizeof(struct Footer))) return MESSAGEERR_FOOTERCRC; return MESSAGEERR_NONE;