All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Brindle <brindle@quarksecurity.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: selinux@tycho.nsa.gov
Subject: Re: [PATCH] Correctly detect unknown classes in sepol_string_to_security_class
Date: Tue, 21 Jun 2016 10:25:31 -0400	[thread overview]
Message-ID: <57694E5B.3050604@quarksecurity.com> (raw)
In-Reply-To: <10cfe4a6-2d75-e821-3ed5-fff8704dde17@tycho.nsa.gov>

Stephen Smalley wrote:
> On 06/03/2016 11:17 AM, Joshua Brindle wrote:
>> Bail before running off the end of the class index
>>
>> Change-Id: I47c4eaac3c7d789f8d85047e34e37e3f0bb38b3a
>> Signed-off-by: Joshua Brindle<brindle@quarksecurity.com>
>
> Applied this one and then rewrote it to use hashtab_search().
> Not sure why it wasn't that way in the first place.

Thank you, that was a much better fix that I should have noticed...

>
>> ---
>>   libsepol/src/services.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/libsepol/src/services.c b/libsepol/src/services.c
>> index d64a8e8..665fcaa 100644
>> --- a/libsepol/src/services.c
>> +++ b/libsepol/src/services.c
>> @@ -1155,7 +1155,7 @@ int hidden sepol_string_to_security_class(const char *class_name,
>>   	char *class = NULL;
>>   	sepol_security_class_t id;
>>
>> -	for (id = 1;; id++) {
>> +	for (id = 1; id<= policydb->p_classes.nprim; id++) {
>>   		class = policydb->p_class_val_to_name[id - 1];
>>   		if (class == NULL) {
>>   			ERR(NULL, "could not convert %s to class id", class_name);
>> @@ -1166,6 +1166,8 @@ int hidden sepol_string_to_security_class(const char *class_name,
>>   			return STATUS_SUCCESS;
>>   		}
>>   	}
>> +	ERR(NULL, "unrecognized class %s", class_name);
>> +	return -EINVAL;
>>   }
>>
>>   /*
>>
>

  reply	other threads:[~2016-06-21 14:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03 15:09 [PATCH 1/2] Modify audit2why analyze function to use loaded policy Joshua Brindle
2016-06-03 15:09 ` [PATCH 2/2] Correctly detect unknown classes in sepol_string_to_security_class Joshua Brindle
2016-06-03 15:17   ` [PATCH] " Joshua Brindle
2016-06-03 15:18     ` Joshua Brindle
2016-06-20 20:34     ` Stephen Smalley
2016-06-21 14:25       ` Joshua Brindle [this message]
2016-06-20 20:33 ` [PATCH 1/2] Modify audit2why analyze function to use loaded policy 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=57694E5B.3050604@quarksecurity.com \
    --to=brindle@quarksecurity.com \
    --cc=sds@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.