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

[Xen-changelog] [xen-unstable] [ACM] Don't use uninitialised struct value if hypercall fails.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID de99c7f7aba47154810bf282259cc87e5c3bc58f
# Parent  e3c70530cb2875319ff679f6f814116ccd94a6f4
[ACM] Don't use uninitialised struct value if hypercall fails.
From: Jan Beulich <jbeulich@xxxxxxxxxx>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/python/xen/lowlevel/acm/acm.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff -r e3c70530cb28 -r de99c7f7aba4 tools/python/xen/lowlevel/acm/acm.c
--- a/tools/python/xen/lowlevel/acm/acm.c       Fri Oct 20 11:00:08 2006 +0100
+++ b/tools/python/xen/lowlevel/acm/acm.c       Mon Oct 23 09:57:24 2006 +0100
@@ -147,9 +147,10 @@ static PyObject *getdecision(PyObject * 
 {
     char *arg1_name, *arg1, *arg2_name, *arg2, *decision = NULL;
     struct acm_getdecision getdecision;
-    int xc_handle;
-
-    if (!PyArg_ParseTuple(args, "ssss", &arg1_name, &arg1, &arg2_name, &arg2)) 
{
+    int xc_handle, rc;
+
+    if (!PyArg_ParseTuple(args, "ssss", &arg1_name,
+                          &arg1, &arg2_name, &arg2)) {
         return NULL;
     }
 
@@ -179,12 +180,16 @@ static PyObject *getdecision(PyObject * 
         getdecision.id2.ssidref = atol(arg2);
     }
 
-    if (xc_acm_op(xc_handle, ACMOP_getdecision, &getdecision, 
sizeof(getdecision)) < 0) {
+    rc = xc_acm_op(xc_handle, ACMOP_getdecision,
+                   &getdecision, sizeof(getdecision));
+
+    xc_interface_close(xc_handle);
+
+    if (rc < 0) {
         if (errno == EACCES)
             PERROR("ACM operation failed.");
-    }
-
-    xc_interface_close(xc_handle);
+        return NULL;
+    }
 
     if (getdecision.acm_decision == ACM_ACCESS_PERMITTED)
         decision = "PERMITTED";

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.