Hello, the change looks good to me. (I was delaying my OK hoping someone else will chip-in with OK for iked & ipsecctl stuff).
IMO It makes sense to keep parse.y code in sync where possible, so go for it. OK sashan. On Thu, Nov 01, 2018 at 04:14:53PM +0800, Michael Mikonos wrote: > Hello, > > When I updated cmdline_symset() in parse.y in the following commit > I missed src/sbin/{iked,ipsecctl,pfctl}/parse.y. OK to update them? > > https://marc.info/?l=openbsd-cvs&m=153631079505256&w=2 > > > Index: iked/parse.y > =================================================================== > RCS file: /cvs/src/sbin/iked/parse.y,v > retrieving revision 1.76 > diff -u -p -u -r1.76 parse.y > --- iked/parse.y 1 Nov 2018 00:18:44 -0000 1.76 > +++ iked/parse.y 1 Nov 2018 07:03:31 -0000 > @@ -1660,17 +1660,13 @@ cmdline_symset(char *s) > { > char *sym, *val; > int ret; > - size_t len; > > if ((val = strrchr(s, '=')) == NULL) > return (-1); > > - len = strlen(s) - strlen(val) + 1; > - if ((sym = malloc(len)) == NULL) > + sym = strndup(s, val - s); > + if (sym == NULL) > err(1, "%s", __func__); > - > - strlcpy(sym, s, len); > - > ret = symset(sym, val + 1, 1); > free(sym); > > Index: ipsecctl/parse.y > =================================================================== > RCS file: /cvs/src/sbin/ipsecctl/parse.y,v > retrieving revision 1.174 > diff -u -p -u -r1.174 parse.y > --- ipsecctl/parse.y 1 Nov 2018 00:18:44 -0000 1.174 > +++ ipsecctl/parse.y 1 Nov 2018 07:03:32 -0000 > @@ -1426,17 +1426,13 @@ cmdline_symset(char *s) > { > char *sym, *val; > int ret; > - size_t len; > > if ((val = strrchr(s, '=')) == NULL) > return (-1); > > - len = strlen(s) - strlen(val) + 1; > - if ((sym = malloc(len)) == NULL) > + sym = strndup(s, val - s); > + if (sym == NULL) > err(1, "%s", __func__); > - > - strlcpy(sym, s, len); > - > ret = symset(sym, val + 1, 1); > free(sym); > > Index: pfctl/parse.y > =================================================================== > RCS file: /cvs/src/sbin/pfctl/parse.y,v > retrieving revision 1.685 > diff -u -p -u -r1.685 parse.y > --- pfctl/parse.y 1 Nov 2018 00:18:44 -0000 1.685 > +++ pfctl/parse.y 1 Nov 2018 07:03:34 -0000 > @@ -5564,11 +5564,9 @@ pfctl_cmdline_symset(char *s) > if ((val = strrchr(s, '=')) == NULL) > return (-1); > > - if ((sym = malloc(strlen(s) - strlen(val) + 1)) == NULL) > + sym = strndup(s, val - s); > + if (sym == NULL); > err(1, "%s", __func__); > - > - strlcpy(sym, s, strlen(s) - strlen(val) + 1); > - > ret = symset(sym, val + 1, 1); > free(sym); > >