Skip to content

Commit 0f044e2

Browse files
author
Hannes Gredler
committed
use 63/64 bit arithmethic, such that Fletcher checksum calculation does not overflow beyond 5803 bytes.
1 parent b1bdce9 commit 0f044e2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

code/lspgen/src/lspgen_packet.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ lspgen_gen_packet_header(lsdb_ctx_t *ctx, lsdb_node_t *node, lsdb_packet_t *pack
103103
* The checksum field of the passed PDU does not need to be reset to zero.
104104
*/
105105
uint16_t
106-
calculate_fletcher_cksum(const uint8_t *pptr, int checksum_offset, int length)
106+
calculate_fletcher_cksum(const uint8_t *pptr, uint checksum_offset, uint length)
107107
{
108108

109-
int x, y;
110-
uint32_t mul, c0, c1;
111-
int idx;
109+
int64_t x, y;
110+
uint64_t mul, c0, c1;
111+
uint idx;
112112

113113
c0 = 0;
114114
c1 = 0;

0 commit comments

Comments
 (0)