libselinux: Correct line count for property and service contexts files
diff mbox

Message ID 1448286761-4903-1-git-send-email-richard_c_haines@btinternet.com
State Accepted
Headers show

Commit Message

Richard Haines Nov. 23, 2015, 1:52 p.m. UTC
When a line number is displayed for context errors they are
x2 the correct value, so reset line count for each pass.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
---
 libselinux/src/label_android_property.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jeffrey Vander Stoep Nov. 23, 2015, 6:55 p.m. UTC | #1
Acked-by: Jeff Vander Stoep <jeffv@google.com>

Already merged into AOSP.

On Mon, Nov 23, 2015 at 5:56 AM Richard Haines <
richard_c_haines@btinternet.com> wrote:

> When a line number is displayed for context errors they are
> x2 the correct value, so reset line count for each pass.
>
> Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
> ---
>  libselinux/src/label_android_property.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libselinux/src/label_android_property.c
> b/libselinux/src/label_android_property.c
> index 712eecb..fea1f8f 100644
> --- a/libselinux/src/label_android_property.c
> +++ b/libselinux/src/label_android_property.c
> @@ -132,7 +132,7 @@ static int init(struct selabel_handle *rec, const
> struct selinux_opt *opts,
>         const char *path = NULL;
>         FILE *fp;
>         char line_buf[BUFSIZ];
> -       unsigned int lineno = 0, maxnspec, pass;
> +       unsigned int lineno, maxnspec, pass;
>         int status = -1;
>         struct stat sb;
>
> @@ -166,6 +166,7 @@ static int init(struct selabel_handle *rec, const
> struct selinux_opt *opts,
>         maxnspec = UINT_MAX / sizeof(spec_t);
>         for (pass = 0; pass < 2; pass++) {
>                 data->nspec = 0;
> +               lineno = 0;
>
>                 while (fgets(line_buf, sizeof(line_buf) - 1, fp)
>                        && data->nspec < maxnspec) {
> --
> 2.5.0
>
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to
> Selinux-request@tycho.nsa.gov.
>
Stephen Smalley Nov. 24, 2015, 9:39 p.m. UTC | #2
On 11/23/2015 08:52 AM, Richard Haines wrote:
> When a line number is displayed for context errors they are
> x2 the correct value, so reset line count for each pass.
>
> Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>

Thanks, applied.

> ---
>   libselinux/src/label_android_property.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libselinux/src/label_android_property.c b/libselinux/src/label_android_property.c
> index 712eecb..fea1f8f 100644
> --- a/libselinux/src/label_android_property.c
> +++ b/libselinux/src/label_android_property.c
> @@ -132,7 +132,7 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
>   	const char *path = NULL;
>   	FILE *fp;
>   	char line_buf[BUFSIZ];
> -	unsigned int lineno = 0, maxnspec, pass;
> +	unsigned int lineno, maxnspec, pass;
>   	int status = -1;
>   	struct stat sb;
>
> @@ -166,6 +166,7 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
>   	maxnspec = UINT_MAX / sizeof(spec_t);
>   	for (pass = 0; pass < 2; pass++) {
>   		data->nspec = 0;
> +		lineno = 0;
>
>   		while (fgets(line_buf, sizeof(line_buf) - 1, fp)
>   		       && data->nspec < maxnspec) {
>

Patch
diff mbox

diff --git a/libselinux/src/label_android_property.c b/libselinux/src/label_android_property.c
index 712eecb..fea1f8f 100644
--- a/libselinux/src/label_android_property.c
+++ b/libselinux/src/label_android_property.c
@@ -132,7 +132,7 @@  static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
 	const char *path = NULL;
 	FILE *fp;
 	char line_buf[BUFSIZ];
-	unsigned int lineno = 0, maxnspec, pass;
+	unsigned int lineno, maxnspec, pass;
 	int status = -1;
 	struct stat sb;
 
@@ -166,6 +166,7 @@  static int init(struct selabel_handle *rec, const struct selinux_opt *opts,
 	maxnspec = UINT_MAX / sizeof(spec_t);
 	for (pass = 0; pass < 2; pass++) {
 		data->nspec = 0;
+		lineno = 0;
 
 		while (fgets(line_buf, sizeof(line_buf) - 1, fp)
 		       && data->nspec < maxnspec) {