Patchwork [1/2] acl: Fix acl_remove not to mess up the ACL

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 15, 2013, 2:24 p.m.
Message ID <1358259856-9422-2-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/212170/
State New
Headers show

Comments

Markus Armbruster - Jan. 15, 2013, 2:24 p.m.
It leaks memory and fails to adjust qemu_acl member nentries.  Future
acl_add become confused: can misreport the position, and can silently
fail to add.

Cc: qemu-stable@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 util/acl.c | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/util/acl.c b/util/acl.c
index 81ac255..21b2205 100644
--- a/util/acl.c
+++ b/util/acl.c
@@ -168,6 +168,9 @@  int qemu_acl_remove(qemu_acl *acl,
         i++;
         if (strcmp(entry->match, match) == 0) {
             QTAILQ_REMOVE(&acl->entries, entry, next);
+            acl->nentries--;
+            g_free(entry->match);
+            g_free(entry);
             return i;
         }
     }