All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Richard Haines <richard_c_haines@btinternet.com>, selinux@tycho.nsa.gov
Subject: Re: [PATCH] libselinux: Fix if file_contexts not '\n' terminated
Date: Fri, 26 Jun 2015 08:09:32 -0400	[thread overview]
Message-ID: <558D40FC.8060901@tycho.nsa.gov> (raw)
In-Reply-To: <1435314596-14501-1-git-send-email-richard_c_haines@btinternet.com>

On 06/26/2015 06:29 AM, Richard Haines wrote:
> If the last line of a file_contexts file is not '\n' terminated
> it failed to read the entry and gave an invalid file type error.
> read_spec_entries now handles this situation.
> 
> Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
> ---
>  libselinux/src/label_support.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libselinux/src/label_support.c b/libselinux/src/label_support.c
> index cf91dfa..e67d89a 100644
> --- a/libselinux/src/label_support.c
> +++ b/libselinux/src/label_support.c
> @@ -57,6 +57,11 @@ int hidden read_spec_entries(char *line_buf, int num_args, ...)
>  	len = strlen(line_buf);
>  	if (line_buf[len - 1] == '\n')
>  		line_buf[len - 1] = '\0';
> +	else
> +		/* Handle case if line not \n terminated by bumping
> +		 * the len for the check below (as the line is NUL
> +		 * terminated by getline(3)) */
> +		len++;
>  
>  	buf_p = line_buf;
>  	while (isspace(*buf_p))
> 

Hmm..seems like the problem is more general.  Try adding some trailing
whitespace to the end of a file_contexts line and you'll also encounter
the problem.

      reply	other threads:[~2015-06-26 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26 10:29 [PATCH] libselinux: Fix if file_contexts not '\n' terminated Richard Haines
2015-06-26 12:09 ` 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=558D40FC.8060901@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=richard_c_haines@btinternet.com \
    --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.