* [PATCH] libselinux: Fix if file_contexts not '\n' terminated
@ 2015-06-26 10:29 Richard Haines
2015-06-26 12:09 ` Stephen Smalley
0 siblings, 1 reply; 2+ messages in thread
From: Richard Haines @ 2015-06-26 10:29 UTC (permalink / raw)
To: selinux
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))
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libselinux: Fix if file_contexts not '\n' terminated
2015-06-26 10:29 [PATCH] libselinux: Fix if file_contexts not '\n' terminated Richard Haines
@ 2015-06-26 12:09 ` Stephen Smalley
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Smalley @ 2015-06-26 12:09 UTC (permalink / raw)
To: Richard Haines, selinux
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-26 12:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26 10:29 [PATCH] libselinux: Fix if file_contexts not '\n' terminated Richard Haines
2015-06-26 12:09 ` Stephen Smalley
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.