All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Gyurdiev <ivg2@cornell.edu>
To: selinux@tycho.nsa.gov
Subject: Re: [ SEPOL ] Fix memory leaks
Date: Tue, 20 Sep 2005 16:45:12 -0400	[thread overview]
Message-ID: <433074D8.3030507@cornell.edu> (raw)
In-Reply-To: <432FBD08.2050903@cornell.edu>

[-- Attachment #1: Type: text/plain, Size: 302 bytes --]

The attached patch applies on top of the sepol patch (or at least..I 
hope it does - might complain about whitespace). It fixes memory leaks 
noticed by Steven Smalley, and removes the prototypes of two functions 
that are only used internally (there's a lot more, but this gets rid of 
two of them).


[-- Attachment #2: libsepol.fix.memory_leaks2.diff --]
[-- Type: text/x-patch, Size: 2489 bytes --]

diff -Naur libsepol.new/include/sepol/interfaces.h libsepol/include/sepol/interfaces.h
--- libsepol.new/include/sepol/interfaces.h	2005-09-20 02:55:29.000000000 -0400
+++ libsepol/include/sepol/interfaces.h	2005-09-20 16:34:11.000000000 -0400
@@ -5,13 +5,6 @@
 #include <sepol/iface_record.h>
 #include <stddef.h>
 
-/* Create a low level interface structure from
- * a high level representation */
-extern int sepol_iface_struct_create(
-	policydb_t* policydb,
-	ocontext_t** iface,
-	sepol_iface_t data);
-
 /* Get the current context mapping for this interface */
 extern int sepol_iface_get_context(
 	policydb_t* policydb,
diff -Naur libsepol.new/include/sepol/ports.h libsepol/include/sepol/ports.h
--- libsepol.new/include/sepol/ports.h	2005-09-14 11:44:44.000000000 -0400
+++ libsepol/include/sepol/ports.h	2005-09-20 16:34:18.000000000 -0400
@@ -5,12 +5,6 @@
 #include <sepol/port_record.h>
 #include <stddef.h>
 
-/* Create a port structure from high level representation */
-extern int sepol_port_struct_create(
-	policydb_t* policydb,
-	ocontext_t** port,
-	sepol_port_t data);
-
 /* Get the current context mapping
  * for this port. Returns 1 if no match, -1 on error, 0 on
  * success. The returned data is allocated on the heap */
diff -Naur libsepol.new/src/booleans.c libsepol/src/booleans.c
--- libsepol.new/src/booleans.c	2005-09-20 16:39:34.000000000 -0400
+++ libsepol/src/booleans.c	2005-09-20 16:39:24.000000000 -0400
@@ -33,6 +33,8 @@
 		DEBUG(__FUNCTION__, "illegal value %d for boolean %s\n", value, name);
 		goto err;
 	}
+
+	free(name);
 	datum->state = value;
 	return STATUS_SUCCESS;
 
diff -Naur libsepol.new/src/interfaces.c libsepol/src/interfaces.c
--- libsepol.new/src/interfaces.c	2005-09-20 02:55:29.000000000 -0400
+++ libsepol/src/interfaces.c	2005-09-20 16:33:11.000000000 -0400
@@ -51,6 +51,7 @@
 	DEBUG(__FUNCTION__, "out of memory\n");
 
 	err:
+	free(tmp_iface->u.name);
 	free(tmp_iface);
 	DEBUG(__FUNCTION__, "error creating interface structure\n");
 	return STATUS_ERR;
@@ -126,6 +127,7 @@
 
 	err:
 	DEBUG(__FUNCTION__, "error while loading interface %s\n", name);
+	free(iface->u.name);
 	free(iface);
 	return STATUS_ERR;
 }
diff -Naur libsepol.new/src/users.c libsepol/src/users.c
--- libsepol.new/src/users.c	2005-09-20 16:39:50.000000000 -0400
+++ libsepol/src/users.c	2005-09-20 16:39:06.000000000 -0400
@@ -102,6 +102,7 @@
 	if (sepol_user_load(policydb, user) < 0) 
 		goto err;
 
+	free(name);
 	return STATUS_SUCCESS;
 
 	omem:

  parent reply	other threads:[~2005-09-20 20:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-20  7:40 [ SEPOL/SEMANAGE ] Boolean record Ivan Gyurdiev
2005-09-20 19:06 ` Stephen Smalley
2005-09-20 19:35   ` Ivan Gyurdiev
2005-09-20 19:56     ` Stephen Smalley
2005-09-20 20:16       ` Ivan Gyurdiev
2005-09-20 20:22         ` Stephen Smalley
2005-09-20 20:48         ` Karl MacMillan
2005-09-20 21:07           ` Ivan Gyurdiev
2005-09-21 14:21             ` Stephen Smalley
2005-09-21 16:14               ` Ivan Gyurdiev
2005-09-20 21:42           ` Ivan Gyurdiev
2005-09-21 14:35             ` Stephen Smalley
2005-09-21 17:48             ` Karl MacMillan
2005-09-21 17:51               ` Stephen Smalley
2005-09-21 17:53               ` Stephen Smalley
2005-09-21 18:03                 ` Karl MacMillan
2005-09-21 18:37               ` Ivan Gyurdiev
2005-09-21 18:33                 ` Karl MacMillan
2005-09-22  1:50                   ` Ivan Gyurdiev
2005-09-23 12:34                     ` Karl MacMillan
2005-09-20 20:45 ` Ivan Gyurdiev [this message]
2005-09-21 14:44   ` [ SEPOL ] Fix memory leaks Stephen Smalley
2005-09-21 14:41 ` [ SEPOL/SEMANAGE ] Boolean record Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=433074D8.3030507@cornell.edu \
    --to=ivg2@cornell.edu \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.