]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix crash on OOM in xenParseSxpr
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 08:30:20 +0000 (09:30 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 17:12:08 +0000 (18:12 +0100)
The xenParseSxpr method sets def->nconsoles to 1 before allocating
the def->consoles array. If the allocation fails due to OOM the
cleanup code will thus crash accessing out of bounds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/xenxs/xen_sxpr.c

index 6209c683a659dbd34f478171d9158eaa217ed1f1..462eac6a99e9aaba7a990a72981a129eaa8d95ca 100644 (file)
@@ -1439,9 +1439,9 @@ xenParseSxpr(const struct sexpr *root,
             def->parallels[def->nparallels++] = chr;
         }
     } else if (def->id != 0) {
-        def->nconsoles = 1;
         if (VIR_ALLOC_N(def->consoles, 1) < 0)
             goto error;
+        def->nconsoles = 1;
         /* Fake a paravirt console, since that's not in the sexpr */
         if (!(def->consoles[0] = xenParseSxprChar("pty", tty)))
             goto error;