From 0f044e2289c068cbd67bad4bfab087974c1b7074 Mon Sep 17 00:00:00 2001 From: Hannes Gredler Date: Fri, 19 Jan 2024 12:18:32 +0000 Subject: [PATCH] use 63/64 bit arithmethic, such that Fletcher checksum calculation does not overflow beyond 5803 bytes. --- code/lspgen/src/lspgen_packet.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/lspgen/src/lspgen_packet.c b/code/lspgen/src/lspgen_packet.c index eb937d9f..011ff6ed 100644 --- a/code/lspgen/src/lspgen_packet.c +++ b/code/lspgen/src/lspgen_packet.c @@ -103,12 +103,12 @@ lspgen_gen_packet_header(lsdb_ctx_t *ctx, lsdb_node_t *node, lsdb_packet_t *pack * The checksum field of the passed PDU does not need to be reset to zero. */ uint16_t -calculate_fletcher_cksum(const uint8_t *pptr, int checksum_offset, int length) +calculate_fletcher_cksum(const uint8_t *pptr, uint checksum_offset, uint length) { - int x, y; - uint32_t mul, c0, c1; - int idx; + int64_t x, y; + uint64_t mul, c0, c1; + uint idx; c0 = 0; c1 = 0;