From: Stefan Hajnoczi Date: Wed, 15 Jul 2015 17:17:04 +0000 (+0100) Subject: rtl8139: check TCP Data Offset field X-Git-Tag: qemu-xen-4.6.0-rc1~1 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=94db81945c93c679fb5d2eb7d3beb98802f99d93;p=qemu-upstream-unstable.git rtl8139: check TCP Data Offset field The TCP Data Offset field contains the length of the header. Make sure it is valid and does not exceed the IP data length. Signed-off-by: Stefan Hajnoczi Signed-off-by: Stefano Stabellini --- diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index c8f0df9ac..2df4a51c8 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -2253,6 +2253,11 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s) int tcp_hlen = TCP_HEADER_DATA_OFFSET(p_tcp_hdr); + /* Invalid TCP data offset? */ + if (tcp_hlen < sizeof(tcp_header) || tcp_hlen > ip_data_len) { + goto skip_offload; + } + /* ETH_MTU = ip header len + tcp header len + payload */ int tcp_data_len = ip_data_len - tcp_hlen; int tcp_chunk_size = ETH_MTU - hlen - tcp_hlen;