selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: "Jokke Hämäläinen" <jokke.hamalainen@kolttonen.fi>,
	selinux@vger.kernel.org
Subject: Re: [PATCH] trivial kernel_to_conf.c checks
Date: Fri, 14 Jun 2019 15:38:37 -0400	[thread overview]
Message-ID: <d6a21545-82e5-6e0d-e802-7be986a4e3b6@tycho.nsa.gov> (raw)
In-Reply-To: <alpine.LFD.2.21.1905250034390.11070@34-41-5D-CA-59-C7>

On 5/24/19 5:36 PM, Jokke Hämäläinen wrote:

Re-post with Signed-off-by line please.

> 
> diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c
> index 4f84ee8b..930bafab 100644
> --- a/libsepol/src/kernel_to_conf.c
> +++ b/libsepol/src/kernel_to_conf.c
> @@ -448,8 +448,12 @@ static int write_sids_to_conf(FILE *out, const char *const *sid_to_str,
>   		if (i < num_sids) {
>   			sid = (char *)sid_to_str[i];
>   		} else {
> -			snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
> +			snprintf(unknown, sizeof(unknown), "%s%u", "UNKNOWN", i);
>   			sid = strdup(unknown);
> +			if (!sid) {
> +				rc = -1;
> +				goto exit;
> +			}
>   		}
>   		rc = strs_add_at_index(strs, sid, i);
>   		if (rc != 0) {
> @@ -792,6 +796,10 @@ static int write_sensitivity_rules_to_conf(FILE *out, struct policydb *pdb)
>   			j = level->level->sens - 1;
>   			if (!sens_alias_map[j]) {
>   				sens_alias_map[j] = strdup(name);
> +				if (!sens_alias_map[j]) {
> +					rc = -1;
> +					goto exit;
> +				}
>   			} else {
>   				alias = sens_alias_map[j];
>   				sens_alias_map[j] = create_str("%s %s", 2, alias, name);
> @@ -919,6 +927,10 @@ static int write_category_rules_to_conf(FILE *out, struct policydb *pdb)
>   			j = cat->s.value - 1;
>   			if (!cat_alias_map[j]) {
>   				cat_alias_map[j] = strdup(name);
> +				if (!cat_alias_map[j]) {
> +					rc = -1;
> +					goto exit;
> +				}
>   			} else {
>   				alias = cat_alias_map[j];
>   				cat_alias_map[j] = create_str("%s %s", 2, alias, name);
> @@ -2364,7 +2376,7 @@ static int write_sid_context_rules_to_conf(FILE *out, struct policydb *pdb, cons
>   		if (i < num_sids) {
>   			sid = (char *)sid_to_str[i];
>   		} else {
> -			snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
> +			snprintf(unknown, sizeof(unknown), "%s%u", "UNKNOWN", i);
>   			sid = unknown;
>   		}
>   
> 


      reply	other threads:[~2019-06-14 19:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 21:36 [PATCH] trivial kernel_to_conf.c checks Jokke Hämäläinen
2019-06-14 19:38 ` Stephen Smalley [this message]

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=d6a21545-82e5-6e0d-e802-7be986a4e3b6@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=jokke.hamalainen@kolttonen.fi \
    --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).