Re: [nft PATCH v2] parser_bison: Fix for bison < 3.6
Phil Sutter <[email protected]> Thu, 23 Jul 2026 12:09:14 +0200
| Newsgroups | gmane.comp.security.firewalls.netfilter.devel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Jun 11, 2026 at 02:52:25PM +0200, Phil Sutter wrote: > Support for 'custom' parse.error value was added in bison-3.6. Fall back > to previous value for earlier versions. > > This is harder to get right than it seems: On one hand, preprocessor > macros can't be used in parser_bison.y's declaration section and > automake forbids conditional changes to AM_YFLAGS on the other. > > Another aspect complicating things is compiling with (an up to date) > parser_bison.c in place vs. without: Dist tarballs generally have it in > place, relieving users from having to provide a YACC when compiling. The > existing parser_bison.c either uses parse.error=custom or not which does > not (should not) change when compiling. Hiding yyreport_syntax_error() > behind a CPPFLAG which may be set or not depending on bison presence and > version then causes trouble if it doesn't match how parser_bison.c was > created. > > Avoid these pitfalls by: > - Not relying upon a preprocessor define to control parser_bison.c > compilation, instead check existence of the bison-internal > YY_LAC_ESTABLISH macro > - Exporting the above macro existence check in a variable for use by > main.c (thereby crossing the libnftables library boundary) > > Also: > - Introduce have_prebuilt_bison variable in configure.ac, unifying the > parser_bison.c existence check and solidify the latter by also > comparing its timestamp > - Report extended parser errors enableval in configure only if > parser_bison.c will be recreated, otherwise we can't quite tell if it > will turn out to be enabled or not > > Suggested-by: Jan Kończak <[email protected]> > Fixes: 67b822f2b2624 ("parser_bison: on syntax errors, output expected tokens") > Signed-off-by: Phil Sutter <[email protected]> Patch applied.