Hello,

On Mon, Jul 23, 2018 at 11:16:16AM +0200, Klemens Nanni wrote:
> strtonum(3) is simpler than checking three cases for `q' and gives nicer
> error messages. While here, use `v6mask' as maximum netmask instead of
> hardcoding it.
> 
> OK?

    I'm OK with your change. I have just one small note, which is
    more matter of my personal 'coding taste/style' than anything else.
> 
> Index: pfctl_parser.c
> ===================================================================
> RCS file: /cvs/src/sbin/pfctl/pfctl_parser.c,v
> retrieving revision 1.321
> diff -u -p -r1.321 pfctl_parser.c
> --- pfctl_parser.c    10 Jul 2018 09:30:49 -0000      1.321
> +++ pfctl_parser.c    21 Jul 2018 18:44:57 -0000
> @@ -1635,7 +1635,8 @@ host(const char *s, int opts)
>  {
>       struct node_host        *h = NULL, *n;
>       int                      mask = -1, v4mask = 32, v6mask = 128, cont = 1;
> -     char                    *p, *q, *r, *ps, *if_name;
> +     char                    *p, *r, *ps, *if_name;
> +     const char              *errstr;
>  
>       if ((ps = strdup(s)) == NULL)
>               err(1, "host: strdup");
> @@ -1648,9 +1649,9 @@ host(const char *s, int opts)
>       if ((p = strrchr(ps, '/')) != NULL) {
>               if ((r = strdup(ps)) == NULL)
>                       err(1, "host: strdup");
> -             mask = strtol(p+1, &q, 0);
> -             if (!q || *q || mask > 128 || q == (p+1)) {
> -                     fprintf(stderr, "invalid netmask '%s'\n", p);
> +             mask = strtonum(p+1, 0, v6mask, &errstr);

    IMO using a constant (being it 128 or V6MASK or ...) is better
    option than using v6mask variable here. But as I've said earlier
    it's a nit.


regards
sashan

Reply via email to