WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxl: correct allocation size in libxl_l

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxl: correct allocation size in libxl_list_vm
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Thu, 29 Sep 2011 02:00:18 +0100
Delivery-date: Wed, 28 Sep 2011 18:05:25 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1317224040 -3600
# Node ID 8877da7ba3a43dc39870bd6defa8d195b87fbaa8
# Parent  ba1afb9bc1597bec2c2c54113ce1e39241dcf86e
libxl: correct allocation size in libxl_list_vm

*ptr has type libxl_vminfo not libxl_domid, so correct calloc call.

This the second instance of this bug I've noticed recently, I did a
quick audit of other similar uses of sizeof(...) and all I spotted
were a couple of harmlessly reversed calloc arguments. It's a pretty
strong argument for "foo = ..alloc(sizeof(*foo))" rather than
"alloc(sizeof(foos_type))" though...

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r ba1afb9bc159 -r 8877da7ba3a4 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Sep 28 16:32:31 2011 +0100
+++ b/tools/libxl/libxl.c       Wed Sep 28 16:34:00 2011 +0100
@@ -449,7 +449,7 @@
     xc_domaininfo_t info[1024];
     int size = 1024;
 
-    ptr = calloc(size, sizeof(libxl_dominfo));
+    ptr = calloc(size, sizeof(libxl_vminfo));
     if (!ptr)
         return NULL;
 
diff -r ba1afb9bc159 -r 8877da7ba3a4 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Wed Sep 28 16:32:31 2011 +0100
+++ b/tools/libxl/libxl_dm.c    Wed Sep 28 16:34:00 2011 +0100
@@ -774,7 +774,7 @@
     libxl_domain_unpause(ctx, domid);
 
     if (starting_r) {
-        *starting_r = calloc(sizeof(libxl__device_model_starting), 1);
+        *starting_r = calloc(1, sizeof(libxl__device_model_starting));
         (*starting_r)->domid = info->domid;
         (*starting_r)->dom_path = libxl__xs_get_dompath(gc, info->domid);
         (*starting_r)->for_spawn = NULL;
@@ -851,11 +851,11 @@
 
     if (starting_r) {
         rc = ERROR_NOMEM;
-        *starting_r = calloc(sizeof(libxl__device_model_starting), 1);
+        *starting_r = calloc(1, sizeof(libxl__device_model_starting));
         if (!*starting_r)
             goto out_close;
         p = *starting_r;
-        p->for_spawn = calloc(sizeof(libxl__spawn_starting), 1);
+        p->for_spawn = calloc(1, sizeof(libxl__spawn_starting));
     } else {
         p = &buf_starting;
         p->for_spawn = NULL;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxl: correct allocation size in libxl_list_vm, Xen patchbot-unstable <=