]> xenbits.xensource.com Git - people/andrewcoop/qemu-traditional.git/commitdiff
rtl8139: check TCP Data Offset field master
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 15 Jul 2015 17:17:04 +0000 (18:17 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 10 May 2016 18:11:56 +0000 (19:11 +0100)
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>
[Backport to qemu-xen-tradition]
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
hw/rtl8139.c

index 0bb45832159e625318ffd0380ac6e7e950b28aec..2ca5a9b58f7b657bfe31c1885236b7f47f66a30d 100644 (file)
@@ -2193,6 +2193,11 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
 
                 int tcp_hlen = TCP_HEADER_DATA_OFFSET(p_tcp_hdr);
 
 
                 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;
                 /* 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;