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

[Libguestfs] [PATCH] daemon: Fix crash in aug-defnode (RHBZ#785668).



From: "Richard W.M. Jones" <rjones redhat com>

---
 daemon/augeas.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/daemon/augeas.c b/daemon/augeas.c
index 83d24ad..f52c091 100644
--- a/daemon/augeas.c
+++ b/daemon/augeas.c
@@ -141,18 +141,27 @@ guestfs_int_int_bool *
 do_aug_defnode (const char *name, const char *expr, const char *val)
 {
 #ifdef HAVE_AUG_DEFNODE
-  static guestfs_int_int_bool r;
-  int created;
+  guestfs_int_int_bool *r;
+  int i, created;
 
   NEED_AUG (NULL);
 
-  r.i = aug_defnode (aug, name, expr, val, &created);
-  if (r.i == -1) {
+  i = aug_defnode (aug, name, expr, val, &created);
+  if (i == -1) {
     reply_with_error ("Augeas defnode failed");
     return NULL;
   }
-  r.b = created;
-  return &r;
+
+  r = malloc (sizeof *r);
+  if (r == NULL) {
+    reply_with_perror ("malloc");
+    return NULL;
+  }
+
+  r->i = i;
+  r->b = created;
+
+  return r;
 #else
   NOT_AVAILABLE (NULL);
 #endif
-- 
1.7.6


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