]> xenbits.xensource.com Git - people/liuw/qemu.git/commitdiff
rtl8139: check TCP Data Offset field
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 15 Jul 2015 17:17:04 +0000 (18:17 +0100)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Mon, 3 Aug 2015 13:52:25 +0000 (13:52 +0000)
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 <stefanha@redhat.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
hw/net/rtl8139.c

index c8f0df9aca53b03e49132e096e805348a6433120..2df4a51c84d2e5de31f483650a2ff386572ce4f1 100644 (file)
@@ -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;