From: Petr Lautrbach <plautrba@redhat.com>
To: selinux@vger.kernel.org
Cc: Petr Lautrbach <plautrba@redhat.com>
Subject: [PATCH] mcstrans: Fix check in raw_color()
Date: Wed, 19 Dec 2018 12:45:00 +0100 [thread overview]
Message-ID: <20181219114500.22113-1-plautrba@redhat.com> (raw)
raw_color() uses color_str as an output argument which is assigned to a new
allocated memory. Therefore it should fail when color_str is null; or
when *color_str is not null in order to avoid a memory leak.
Fixes:
>>> selinux.selinux_raw_context_to_color('system_u:system_r:inetd_t:s0')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 0] Error
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---
mcstrans/src/mcscolor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mcstrans/src/mcscolor.c b/mcstrans/src/mcscolor.c
index cc6174bb..6ea1aa97 100644
--- a/mcstrans/src/mcscolor.c
+++ b/mcstrans/src/mcscolor.c
@@ -292,7 +292,7 @@ int raw_color(const security_context_t raw, char **color_str) {
size_t result_size = (N_COLOR * CHARS_PER_COLOR) + 1;
int rc = -1;
- if (!color_str || !*color_str) {
+ if (!color_str || *color_str) {
return -1;
}
--
2.20.0
next reply other threads:[~2018-12-19 11:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-19 11:45 Petr Lautrbach [this message]
2018-12-19 21:44 ` [PATCH] mcstrans: Fix check in raw_color() Nicolas Iooss
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=20181219114500.22113-1-plautrba@redhat.com \
--to=plautrba@redhat.com \
--cc=selinux@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).