slirp: fix use-after-free
authorMark McLoughlin <markmc@redhat.com>
Fri, 20 Nov 2009 18:07:15 +0000 (20 18:07 +0000)
committerMark McLoughlin <markmc@redhat.com>
Fri, 20 Nov 2009 18:19:36 +0000 (20 18:19 +0000)
460fec67ee introduced a use-after free in slirp.

Cc: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Fedora-patch: qemu-slirp-use-after-free.patch

slirp/mbuf.c

index 7652fea..87508ba 100644 (file)
@@ -95,8 +95,8 @@ m_free(struct mbuf *m)
         * Either free() it or put it on the free list
         */
        if (m->m_flags & M_DOFREE) {
-               free(m);
                m->slirp->mbuf_alloced--;
+               free(m);
        } else if ((m->m_flags & M_FREELIST) == 0) {
                insque(m,&m->slirp->m_freelist);
                m->m_flags = M_FREELIST; /* Clobber other flags */