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

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

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]