All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: "Christian Göttsche" <cgzones@googlemail.com>
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH 1/2] checkpolicy: use YYerror only when available
Date: Mon, 25 Mar 2024 13:13:38 -0400	[thread overview]
Message-ID: <CAP+JOzQH0gLqUTmYq5Ou2qt_P9nzvaQY6gscTuQpsU_Mg5rz7Q@mail.gmail.com> (raw)
In-Reply-To: <20240322145049.60340-1-cgzones@googlemail.com>

On Fri, Mar 22, 2024 at 10:54 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> The special error value YYerror is only available since bison 3.6
> (released 2020).  For example the version used by oss-fuzz does not
> support it.
>
> Use a special token in case YYerror is not available.  Only downside is
> a duplicate error message, one from the manual yyerror() call and one
> from within bison for the unexpected special token (which would be
> omitted by using YYerror).
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

For these two patches:
Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  checkpolicy/policy_parse.y | 1 +
>  checkpolicy/policy_scan.l  | 9 ++++++++-
>  2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/checkpolicy/policy_parse.y b/checkpolicy/policy_parse.y
> index e0103502..1b275ebc 100644
> --- a/checkpolicy/policy_parse.y
> +++ b/checkpolicy/policy_parse.y
> @@ -153,6 +153,7 @@ typedef int (* require_func_t)(int pass);
>  %token FILESYSTEM
>  %token DEFAULT_USER DEFAULT_ROLE DEFAULT_TYPE DEFAULT_RANGE
>  %token LOW_HIGH LOW HIGH GLBLUB
> +%token INVALID_CHAR
>
>  %left OR
>  %left XOR
> diff --git a/checkpolicy/policy_scan.l b/checkpolicy/policy_scan.l
> index 1926129c..c4d8e937 100644
> --- a/checkpolicy/policy_scan.l
> +++ b/checkpolicy/policy_scan.l
> @@ -308,7 +308,14 @@ GLBLUB                             { return(GLBLUB); }
>  "]" |
>  "~" |
>  "*"                            { return(yytext[0]); }
> -.                               { yyerror("unrecognized character"); return YYerror; }
> +.                               { yyerror("unrecognized character");
> +/* Available since bison 3.6, avoids duplicate error message */
> +#ifdef YYerror
> +                                 return YYerror;
> +#else
> +                                 return INVALID_CHAR;
> +#endif
> +                               }
>  %%
>  int yyerror(const char *msg)
>  {
> --
> 2.43.0
>
>

  parent reply	other threads:[~2024-03-25 17:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 14:50 [PATCH 1/2] checkpolicy: use YYerror only when available Christian Göttsche
2024-03-22 14:50 ` [PATCH 2/2] checkpolicy: handle unprintable token Christian Göttsche
2024-03-25 17:13 ` James Carter [this message]
2024-03-27 19:07   ` [PATCH 1/2] checkpolicy: use YYerror only when available James Carter

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=CAP+JOzQH0gLqUTmYq5Ou2qt_P9nzvaQY6gscTuQpsU_Mg5rz7Q@mail.gmail.com \
    --to=jwcart2@gmail.com \
    --cc=cgzones@googlemail.com \
    --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 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.