selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libsepol/cil: Do not check flavor when checking for duplicate parameters
@ 2020-03-04 21:28 James Carter
  2020-03-09 12:05 ` Ondrej Mosnacek
  0 siblings, 1 reply; 3+ messages in thread
From: James Carter @ 2020-03-04 21:28 UTC (permalink / raw)
  To: selinux; +Cc: jwcart2, James Carter

A parameter of a macro was only considered to be a duplicate if it
matched both the name and flavor of another parameter. While it is
true that CIL is able to differentiate between those two parameters,
there is no reason to use the same name for two macro parameters and
it is better to return an error for what is probably an error.

Remove the check of the flavors when checking for duplicate parameters.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsepol/cil/src/cil_build_ast.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
index 307b1ee3..fcecdc4f 100644
--- a/libsepol/cil/src/cil_build_ast.c
+++ b/libsepol/cil/src/cil_build_ast.c
@@ -5304,11 +5304,9 @@ int cil_gen_macro(struct cil_db *db, struct cil_tree_node *parse_current, struct
 		struct cil_list_item *curr_param;
 		cil_list_for_each(curr_param, macro->params) {
 			if (param->str == ((struct cil_param*)curr_param->data)->str) {
-				if (param->flavor == ((struct cil_param*)curr_param->data)->flavor) {
-					cil_log(CIL_ERR, "Duplicate parameter\n");
-					cil_destroy_param(param);
-					goto exit;
-				}
+				cil_log(CIL_ERR, "Duplicate parameter\n");
+				cil_destroy_param(param);
+				goto exit;
 			}
 		}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libsepol/cil: Do not check flavor when checking for duplicate parameters
  2020-03-04 21:28 [PATCH] libsepol/cil: Do not check flavor when checking for duplicate parameters James Carter
@ 2020-03-09 12:05 ` Ondrej Mosnacek
  2020-03-11 11:43   ` Ondrej Mosnacek
  0 siblings, 1 reply; 3+ messages in thread
From: Ondrej Mosnacek @ 2020-03-09 12:05 UTC (permalink / raw)
  To: James Carter; +Cc: SElinux list, James Carter

On Wed, Mar 4, 2020 at 10:28 PM James Carter <jwcart2@gmail.com> wrote:
> A parameter of a macro was only considered to be a duplicate if it
> matched both the name and flavor of another parameter. While it is
> true that CIL is able to differentiate between those two parameters,
> there is no reason to use the same name for two macro parameters and
> it is better to return an error for what is probably an error.
>
> Remove the check of the flavors when checking for duplicate parameters.
>
> Signed-off-by: James Carter <jwcart2@gmail.com>
> ---
>  libsepol/cil/src/cil_build_ast.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
> index 307b1ee3..fcecdc4f 100644
> --- a/libsepol/cil/src/cil_build_ast.c
> +++ b/libsepol/cil/src/cil_build_ast.c
> @@ -5304,11 +5304,9 @@ int cil_gen_macro(struct cil_db *db, struct cil_tree_node *parse_current, struct
>                 struct cil_list_item *curr_param;
>                 cil_list_for_each(curr_param, macro->params) {
>                         if (param->str == ((struct cil_param*)curr_param->data)->str) {
> -                               if (param->flavor == ((struct cil_param*)curr_param->data)->flavor) {
> -                                       cil_log(CIL_ERR, "Duplicate parameter\n");
> -                                       cil_destroy_param(param);
> -                                       goto exit;
> -                               }
> +                               cil_log(CIL_ERR, "Duplicate parameter\n");
> +                               cil_destroy_param(param);
> +                               goto exit;
>                         }
>                 }
>
> --
> 2.17.1
>

Acked-by: Ondrej Mosnacek <omosnace@redhat.com>

--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libsepol/cil: Do not check flavor when checking for duplicate parameters
  2020-03-09 12:05 ` Ondrej Mosnacek
@ 2020-03-11 11:43   ` Ondrej Mosnacek
  0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Mosnacek @ 2020-03-11 11:43 UTC (permalink / raw)
  To: James Carter; +Cc: SElinux list, James Carter

On Mon, Mar 9, 2020 at 1:05 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> On Wed, Mar 4, 2020 at 10:28 PM James Carter <jwcart2@gmail.com> wrote:
> > A parameter of a macro was only considered to be a duplicate if it
> > matched both the name and flavor of another parameter. While it is
> > true that CIL is able to differentiate between those two parameters,
> > there is no reason to use the same name for two macro parameters and
> > it is better to return an error for what is probably an error.
> >
> > Remove the check of the flavors when checking for duplicate parameters.
> >
> > Signed-off-by: James Carter <jwcart2@gmail.com>
> > ---
> >  libsepol/cil/src/cil_build_ast.c | 8 +++-----
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
> > index 307b1ee3..fcecdc4f 100644
> > --- a/libsepol/cil/src/cil_build_ast.c
> > +++ b/libsepol/cil/src/cil_build_ast.c
> > @@ -5304,11 +5304,9 @@ int cil_gen_macro(struct cil_db *db, struct cil_tree_node *parse_current, struct
> >                 struct cil_list_item *curr_param;
> >                 cil_list_for_each(curr_param, macro->params) {
> >                         if (param->str == ((struct cil_param*)curr_param->data)->str) {
> > -                               if (param->flavor == ((struct cil_param*)curr_param->data)->flavor) {
> > -                                       cil_log(CIL_ERR, "Duplicate parameter\n");
> > -                                       cil_destroy_param(param);
> > -                                       goto exit;
> > -                               }
> > +                               cil_log(CIL_ERR, "Duplicate parameter\n");
> > +                               cil_destroy_param(param);
> > +                               goto exit;
> >                         }
> >                 }
> >
> > --
> > 2.17.1
> >
>
> Acked-by: Ondrej Mosnacek <omosnace@redhat.com>

Applied, thanks.

-- 
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-11 11:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04 21:28 [PATCH] libsepol/cil: Do not check flavor when checking for duplicate parameters James Carter
2020-03-09 12:05 ` Ondrej Mosnacek
2020-03-11 11:43   ` Ondrej Mosnacek

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).