File CVE-2018-11806-qemut-slirp-correct-size-computation-while-concatenating-mbuf.patch of Package xen.23721
While reassembling incoming fragmented datagrams, 'm_cat' routine
extends the 'mbuf' buffer, if it has insufficient room. It computes
a wrong buffer size, which leads to overwriting adjacent heap buffer
area. Correct this size computation in m_cat.
Reported-by: ZDI Disclosures <address@hidden>
Signed-off-by: Prasad J Pandit <address@hidden>
---
slirp/mbuf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: xen-4.7.5-testing/tools/qemu-xen-traditional-dir-remote/slirp/mbuf.c
===================================================================
--- xen-4.7.5-testing.orig/tools/qemu-xen-traditional-dir-remote/slirp/mbuf.c
+++ xen-4.7.5-testing/tools/qemu-xen-traditional-dir-remote/slirp/mbuf.c
@@ -122,7 +122,7 @@ m_cat(m, n)
* If there's no room, realloc
*/
if (M_FREEROOM(m) < n->m_len)
- m_inc(m,m->m_size+MINCSIZE);
+ m_inc(m, m->m_len + n->m_len);
memcpy(m->m_data+m->m_len, n->m_data, n->m_len);
m->m_len += n->m_len;
@@ -145,6 +145,7 @@ m_inc(m, size)
if (m->m_flags & M_EXT) {
datasize = m->m_data - m->m_ext;
m->m_ext = (char *)realloc(m->m_ext,size);
+ m->m_ext = (char *)realloc(m->m_ext, size + datasize);
/* if (m->m_ext == NULL)
* return (struct mbuf *)NULL;
*/
@@ -152,7 +153,7 @@ m_inc(m, size)
} else {
char *dat;
datasize = m->m_data - m->m_dat;
- dat = (char *)malloc(size);
+ dat = (char *)malloc(size + datasize);
/* if (dat == NULL)
* return (struct mbuf *)NULL;
*/
@@ -163,7 +164,7 @@ m_inc(m, size)
m->m_flags |= M_EXT;
}
- m->m_size = size;
+ m->m_size = size + datasize;
}