This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 05cc04e306b net: preserve checksum state for empty fragments
05cc04e306b is described below
commit 05cc04e306b9fd8ddf898adb91a0a49f22c9789d
Author: Megha Rajput <[email protected]>
AuthorDate: Thu Sep 3 16:11:30 2026 +0000
net: preserve checksum state for empty fragments
checksum() accesses data[0] and calculates an invalid last_byte
pointer when processing an empty fragment with odd state set.
Return early when len is zero to preserve the checksum state and
avoid accessing data from an empty fragment.
Assisted by: GitHub Copilot
Signed-off-by: Megha Rajput <[email protected]>
---
net/utils/net_chksum.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/utils/net_chksum.c b/net/utils/net_chksum.c
index 169c4b7c1bf..6079a7d4e22 100644
--- a/net/utils/net_chksum.c
+++ b/net/utils/net_chksum.c
@@ -61,6 +61,11 @@ uint16_t checksum(uint16_t sum, FAR const uint8_t *data,
FAR const uint8_t *last_byte;
uint16_t t;
+ if (len == 0)
+ {
+ return sum;
+ }
+
dataptr = data;
last_byte = data + len - 1;