From: Stephen Smalley <sds@tycho.nsa.gov>
To: selinux@tycho.nsa.gov
Cc: cefrodrigues@gmail.com, jwcart2@tycho.nsa.gov,
Stephen Smalley <sds@tycho.nsa.gov>
Subject: [PATCH 1/2] libsepol: do not seg fault on sepol_*_key_free(NULL)
Date: Mon, 10 Apr 2017 11:11:47 -0400 [thread overview]
Message-ID: <20170410151148.11958-1-sds@tycho.nsa.gov> (raw)
sepol_*_key_free(NULL) should just be a no-op just like
free(NULL). Fix several instances that did not handle this
correctly and would seg fault if called with NULL.
Test: setsebool -P zebra_write_config=1 while non-root
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
---
libsepol/src/boolean_record.c | 2 ++
libsepol/src/iface_record.c | 2 ++
libsepol/src/user_record.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/libsepol/src/boolean_record.c b/libsepol/src/boolean_record.c
index ebef7f1..a194704 100644
--- a/libsepol/src/boolean_record.c
+++ b/libsepol/src/boolean_record.c
@@ -67,6 +67,8 @@ int sepol_bool_key_extract(sepol_handle_t * handle,
void sepol_bool_key_free(sepol_bool_key_t * key)
{
+ if (!key)
+ return;
free(key->name);
free(key);
}
diff --git a/libsepol/src/iface_record.c b/libsepol/src/iface_record.c
index c8b977c..6d56835 100644
--- a/libsepol/src/iface_record.c
+++ b/libsepol/src/iface_record.c
@@ -73,6 +73,8 @@ int sepol_iface_key_extract(sepol_handle_t * handle,
void sepol_iface_key_free(sepol_iface_key_t * key)
{
+ if (!key)
+ return;
free(key->name);
free(key);
}
diff --git a/libsepol/src/user_record.c b/libsepol/src/user_record.c
index ed5b048..fa95f2d 100644
--- a/libsepol/src/user_record.c
+++ b/libsepol/src/user_record.c
@@ -76,6 +76,8 @@ int sepol_user_key_extract(sepol_handle_t * handle,
void sepol_user_key_free(sepol_user_key_t * key)
{
+ if (!key)
+ return;
free(key->name);
free(key);
}
--
2.9.3
next reply other threads:[~2017-04-10 15:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 15:11 Stephen Smalley [this message]
2017-04-10 15:11 ` [PATCH 2/2] libsemanage: revert "Skip policy module re-link when only setting booleans." 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=20170410151148.11958-1-sds@tycho.nsa.gov \
--to=sds@tycho.nsa.gov \
--cc=cefrodrigues@gmail.com \
--cc=jwcart2@tycho.nsa.gov \
--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.