Otto Moerbeek <[email protected]> wrote:
This lex operation seems ridiculous.
Normal one does lex of free-standing digit sequences into a "number
token" only if the sequence is fully digits -- see the code around
pfctl/parse.y line 5368
Or don't lex numbers instead, but consider them strings (with the correct
seperators), and do the conversion higher in the parse.
What's going on here has been solved in numerous other domain-specific
parse.y adapted originally from pfctl into 30 other parse.y. I was
unaware that sasyncd has a unique parser...
Just commenting; it would be more than a few hours to bring in parse.y
> Meanwhile, I tested a IPv6 setup, it works ok.
> So I'm going to commit the diff below,
>
> -Otto
>
> Index: conf.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/sasyncd/conf.y,v
> retrieving revision 1.19
> diff -u -p -r1.19 conf.y
> --- conf.y 9 Apr 2017 02:40:24 -0000 1.19
> +++ conf.y 21 Mar 2019 10:51:46 -0000
> @@ -325,7 +325,7 @@ yylex(void)
> /* Numerical token? */
> if (isdigit(*confptr)) {
> for (p = confptr; *p; p++)
> - if (*p == '.') /* IP address, or bad input */
> + if (*p == '.' || *p == ':') /* IP address, or bad input
> */
> goto is_string;
> v = (int)strtol(confptr, (char **)NULL, 10);
> yylval.val = v;
> @@ -397,6 +397,9 @@ conf_parse_file(char *cfgfile)
> if (*s == '#') {
> while (*s != '\n' && s < buf + conflen)
> s++;
> + while (*s == '\n' && s < buf + conflen)
> + s++;
> + s--;
> continue;
> }
> if (d == buf && isspace(*s))
>