diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index 3ac20412..e3234d39 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -154,7 +154,7 @@ tcp_input(struct pbuf *p, struct netif *inp) #endif /* CHECKSUM_CHECK_TCP */ /* sanity-check header length */ - hdrlen_bytes = TCPH_HDRLEN(tcphdr) * 4; + hdrlen_bytes = TCPH_HDRLEN_BYTES(tcphdr); if ((hdrlen_bytes < TCP_HLEN) || (hdrlen_bytes > p->tot_len)) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: invalid header length (%"U16_F")\n", (u16_t)hdrlen_bytes)); TCP_STATS_INC(tcp.lenerr); @@ -163,12 +163,12 @@ tcp_input(struct pbuf *p, struct netif *inp) /* Move the payload pointer in the pbuf so that it points to the TCP data instead of the TCP header. */ - tcphdr_optlen = hdrlen_bytes - TCP_HLEN; + tcphdr_optlen = (u16_t)(hdrlen_bytes - TCP_HLEN); tcphdr_opt2 = NULL; if (p->len >= hdrlen_bytes) { /* all options are in the first pbuf */ tcphdr_opt1len = tcphdr_optlen; - pbuf_header(p, -(s16_t)hdrlen_bytes); /* cannot fail */ + pbuf_header(p, (s16_t)-(s16_t)hdrlen_bytes); /* cannot fail */ } else { u16_t opt2len; /* TCP header fits into first pbuf, options don't - data is in the next pbuf */ diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index 9d13e7bb..b3a7ce7c 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -1311,12 +1311,12 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif #endif /* TCP_CHECKSUM_ON_COPY_SANITY_CHECK */ if ((seg->flags & TF_SEG_DATA_CHECKSUMMED) == 0) { LWIP_ASSERT("data included but not checksummed", - seg->p->tot_len == (TCPH_HDRLEN(seg->tcphdr) * 4)); + seg->p->tot_len == TCPH_HDRLEN_BYTES(seg->tcphdr); } /* rebuild TCP header checksum (TCP header changes for retransmissions!) */ acc = ip_chksum_pseudo_partial(seg->p, IP_PROTO_TCP, - seg->p->tot_len, TCPH_HDRLEN(seg->tcphdr) * 4, &pcb->local_ip, &pcb->remote_ip); + seg->p->tot_len, TCPH_HDRLEN_BYTES(seg->tcphdr), &pcb->local_ip, &pcb->remote_ip); /* add payload checksum */ if (seg->chksum_swapped) { seg->chksum = SWAP_BYTES_IN_WORD(seg->chksum);