Files
Jonathan HuiandGitHub e3d03f4f14 [tcplp] fix boundary check in cbuf_reass_write (#12671)
This commit fixes a logic error in the TCP receive buffer reassembly
logic. The issue occurred when an out-of-order segment was exactly
the size of the circular buffer and the write index was non-zero.

The original logic incorrectly used modulo-wrapped indices to check
if a write should be contiguous or split:
start_index + numbytes % size. When numbytes == size, end_index ==
start_index, which evaluates to true, leading to an incorrect memory
write if start_index > 0.

This commit updates the check to use the absolute write boundary:
if (start_index + numbytes <= chdr->size). This ensures that any
write spanning the buffer boundary is correctly split.

A regression test test_cbuf_reass_boundary is added to test_all.c
to verify the fix and prevent future regressions. The test Makefile
is also updated to use $(CC) for better portability.
2026-03-11 14:04:02 -05:00

17 lines
292 B
Makefile

CC?=gcc
CFLAGS=-I ../../../../include -O2 -Wall
all: test_all
%.o: ../%.c
$(CC) -c $(CFLAGS) $< -o $@
test_all.o: test_all.c
$(CC) -c $(CFLAGS) test_all.c -o $@
test_all: test_all.o cbuf.o lbuf.o bitmap.o
$(CC) test_all.o cbuf.o lbuf.o bitmap.o -o test_all
clean:
rm -f *.o test_all