This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch releases/13.1
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/releases/13.1 by this push:
     new ad4a57d93e9 net: preserve checksum state for empty fragments
ad4a57d93e9 is described below

commit ad4a57d93e9011ece59ee291dab5ea8f4fbd271e
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;
 

Reply via email to