On Tue, Feb 02, 2010 at 09:20:01PM +0100, Jim Meyering wrote:
Here's one way to solve this.
Another would be to change the way virXPathNodeSet works, but
there are several other uses of it.
>From 75108240911a1ad943e0bde8ba9ade92ea216f60 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 2 Feb 2010 20:54:01 +0100
Subject: [PATCH] interface_conf.c: don't use a negative value as allocation size
* src/conf/interface_conf.c (virInterfaceDefParseProtoIPv4): If
virXPathNodeSet returns -1, indicate failure by returning -1 right away.
(virInterfaceDefParseProtoIPv6): Likewise.
---
src/conf/interface_conf.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 8a17ed6..510df81 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -1,9 +1,9 @@
/*
* interface_conf.c: interfaces XML handling
*
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
@@ -318,10 +318,12 @@ virInterfaceDefParseProtoIPv4(virConnectPtr conn,
virInterfaceProtocolDefPtr def
if (ret != 0)
return(ret);
}
nIpNodes = virXPathNodeSet(conn, "./ip", ctxt, &ipNodes);
+ if (nIpNodes < 0)
+ return -1;
if (ipNodes == NULL)
return 0;
if (VIR_ALLOC_N(def->ips, nIpNodes) < 0) {
virReportOOMError(conn);
@@ -375,10 +377,12 @@ virInterfaceDefParseProtoIPv6(virConnectPtr conn,
virInterfaceProtocolDefPtr def
if (ret != 0)
return(ret);
}
nIpNodes = virXPathNodeSet(conn, "./ip", ctxt, &ipNodes);
+ if (nIpNodes < 0)
+ return -1;
if (ipNodes == NULL)
return 0;
if (VIR_ALLOC_N(def->ips, nIpNodes) < 0) {
virReportOOMError(conn);
Ah, right !
ACK
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/