Skip to content

Commit 692cbd1

Browse files
committed
lwip: Fix invalid checksum bug
tcp_write() would incorrectly byte swap the checksum 1 too many times when concatenating a pbuf to an existing TCP segment if the number of bytes in the concatenated data was odd. I hit this issue when I tried to reproduce a lost segment issue reported by a mbed user in this forum thread: http://mbed.org/forum/mbed/topic/4354/?page=2#comment-22657
1 parent 5aad98a commit 692cbd1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libraries/net/lwip/lwip/core/tcp_out.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,9 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
646646
last_unsent->len += concat_p->tot_len;
647647
#if TCP_CHECKSUM_ON_COPY
648648
if (concat_chksummed) {
649+
if (concat_chksum_swapped) {
650+
concat_chksum = SWAP_BYTES_IN_WORD(concat_chksum);
651+
}
649652
tcp_seg_add_chksum(concat_chksum, concat_chksummed, &last_unsent->chksum,
650653
&last_unsent->chksum_swapped);
651654
last_unsent->flags |= TF_SEG_DATA_CHECKSUMMED;

0 commit comments

Comments
 (0)