Skip to contentSkip to conversation

libsepol: resource leak in avrule_decl_create

PATCH In review [email protected] 2 participants 2 messages Aug 22, 2005 – Aug 23, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 6/6 libsepol: resource leak in avrule_decl_create

This patch fixes a resource leak found by Coverity:

avrule_decl_destroy(decl) does not free decl itself. Must do so manually on after avrule_decl_destroy().

thanks,
-serge

avrule_block.c +1 -0
Index: src/avrule_block.c
===================================================================
@@ -49,6 +49,7 @@ avrule_decl_t *avrule_decl_create(uint32
         for (i = 0; i < SYM_NUM; i++) {
                 if (symtab_init(&decl->symtab[i], symtab_sizes[i])) {
                         avrule_decl_destroy(decl);
+                        free(decl);
                         return NULL;
                 }
         }

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 4 lines · On Mon, 2005-08-22 at 11:20 -0500, [email protected] wrote:

This patch fixes a resource leak found by Coverity:

avrule_decl_destroy(decl) does not free decl itself. Must do so manually on after avrule_decl_destroy().

It looks to me as if there are still going to be problems in the caller with respect to freeing the data structures already linked into the policydb. In fact, looking at policydb_read since the module support was merged, I see a lot of cases where it is immediately returning -1 rather than doing a goto bad to clean up the partially constructed policydb. Anything after the policydb_init should be doing that upon error.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.