[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 34/26] snapshot: add <disks> to snapshot xml



On 08/19/2011 03:58 PM, Eric Blake wrote:
Adds an optional element to<domainsnapshot>, which will be used
to give user control over external snapshot filenames on input,
and specify generated filenames on output.

Another couple of problems.

+static int
+disksorter(const void *a, const void *b)
+{
+    const virDomainSnapshotDiskDef *diska = a;
+    const virDomainSnapshotDiskDef *diskb = b;
+
+    return diskb->index - diska->index;
+}

Backwards.  Should be a - b.


+
+    /* Provide defaults for all remaining disks.  */
+    if (VIR_EXPAND_N(def->disks, def->ndisks,
+                     def->dom->ndisks - def->ndisks)<  0) {

This updates def->ndisks,

+        virReportOOMError();
+        goto cleanup;
+    }
+
+    for (i = 0; i<  def->dom->ndisks; i++) {
+        virDomainSnapshotDiskDefPtr disk;
+
+        ignore_value(virBitmapGetBit(map, i,&inuse));
+        if (inuse)
+            continue;
+        disk =&def->disks[def->ndisks++];

and this ends up accessing beyond array bounds.

+                ignore_value(virAsprintf(&disk->file, "%*s%s",
+                                         (int) (tmp - original), original,
+                                         def->name));

Needs to be %.*s, not %*s, in order to truncate correctly.

I'll just post a v3 of this patch, instead of adding to the squash list.

--
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]