]> xenbits.xensource.com Git - qemu-upstream-4.3-testing.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 14:18:09 +0000 (14:18 +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>
hw/rtl8139.c

index a81faac0c3ba9155908bef330718c58261cbf89d..e32e4c0c00a1aee179b011aa86d81c158f77c4a4 100644 (file)
@@ -2229,6 +2229,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;