All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/6] libsepol: resource leaks in policydb.c
@ 2005-08-22 16:02 serue
  2005-08-23 13:15 ` Stephen Smalley
  0 siblings, 1 reply; 4+ messages in thread
From: serue @ 2005-08-22 16:02 UTC (permalink / raw)
  To: SELinux

This patch fixes 2 resource leaks found by Coverity in policydb.c.

	1. in avrule_read(), the 'cur' element has been malloc'ed
	but not yet added to the avrule->perms list at one point
	whene we jump to bad:

	2. 'key' is not freed in one case in scope_read().

The second point makes me wonder - is scope_destroy() fully
implemented?  It takes 'key' as an argument, but does nothing with
it.  Same with its third arg.  Of course, they both have attribute
unused...

Hmm, I see now my formatting is not matching what's in the original
file...  I'll fix them by hand as I'm mailing them, and try to get
it right next time.

thanks,
-serge

Index: src/policydb.c
===================================================================
--- src.orig/policydb.c
+++ src/policydb.c
@@ -2027,8 +2027,10 @@ static avrule_t *avrule_read(policydb_t 
                 class_perm_node_init(cur);
 
                 buf = next_entry(fp, sizeof(uint32_t) * 2);
-                if (!buf)
+                if (!buf) {
+                        free(cur);
                         goto bad;
+       }
 
                 cur->class = le32_to_cpu(buf[0]);
                 cur->data = le32_to_cpu(buf[1]);
@@ -2363,7 +2365,8 @@ static int scope_read(policydb_t * p, ha
 
         if (strcmp(key, "object_r") == 0 && h == p->p_roles_scope.table) {
                 /* object_r was already added to this table in roles_init() */
-                scope_destroy(key, scope, NULL);
+                free(key);
+                scope_destroy(NULL, scope, NULL);
         }
         else {
                 if (hashtab_insert(h, key, scope)) {

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-08-25 17:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-22 16:02 [PATCH 3/6] libsepol: resource leaks in policydb.c serue
2005-08-23 13:15 ` Stephen Smalley
2005-08-23 17:20   ` Joshua Brindle
2005-08-25 17:02     ` Stephen Smalley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.