[libvirt] [PATCH 7/7] conf: snapshot: check return value of virDomainSnapshotObjListNum

Ján Tomko jtomko at redhat.com
Wed Nov 28 13:34:51 UTC 2012


If it's negative, this might result in a request to allocate lots of
memory.
---
 src/conf/snapshot_conf.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 72bdd30..06be34d 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -1026,7 +1026,7 @@ virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
     int ret = -1;
     int i;
 
-    if (!snaps)
+    if (!snaps || count < 0)
         return count;
     if (VIR_ALLOC_N(names, count) < 0 ||
         VIR_ALLOC_N(list, count + 1) < 0) {
-- 
1.7.8.6




More information about the libvir-list mailing list