> On 24. Feb 2020, at 20:31, Todd C. Miller <mill...@openbsd.org> wrote: > > I have a mostly-identical patch in my tree, though I tried to improve > readability a bit.
ok jung@ > - todd > > Index: usr.sbin/smtpd/mta_session.c > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/mta_session.c,v > retrieving revision 1.132 > diff -u -p -u -r1.132 mta_session.c > --- usr.sbin/smtpd/mta_session.c 24 Feb 2020 16:16:07 -0000 1.132 > +++ usr.sbin/smtpd/mta_session.c 24 Feb 2020 18:19:22 -0000 > @@ -1295,13 +1295,12 @@ mta_io(struct io *io, int evt, void *arg > if (s->replybuf[0] == '\0') > (void)strlcat(s->replybuf, line, sizeof > s->replybuf); > else if (len > 4) { > - line = line + 4; > - if (isdigit((int)*line) && *(line + 1) == '.' && > - isdigit((int)*line+2) && *(line + 3) == '.' > && > - isdigit((int)*line+4) && > isspace((int)*(line + 5))) > - (void)strlcat(s->replybuf, line+5, > sizeof s->replybuf); > - else > - (void)strlcat(s->replybuf, line, sizeof > s->replybuf); > + p = line + 4; > + if (isdigit((unsigned char)p[0]) && p[1] == '.' > && > + isdigit((unsigned char)p[2]) && p[3] == '.' > && > + isdigit((unsigned char)p[4]) && > isspace((unsigned char)p[5])) > + p += 5; > + (void)strlcat(s->replybuf, p, sizeof > s->replybuf); > } > goto nextline; > } > @@ -1313,9 +1312,9 @@ mta_io(struct io *io, int evt, void *arg > (void)strlcat(s->replybuf, line, sizeof s->replybuf); > else if (len > 4) { > p = line + 4; > - if (isdigit((int)*p) && *(p + 1) == '.' && > - isdigit((int)*p+2) && *(p + 3) == '.' && > - isdigit((int)*p+4) && isspace((int)*(p + 5))) > + if (isdigit((unsigned char)p[0]) && p[1] == '.' && > + isdigit((unsigned char)p[2]) && p[3] == '.' && > + isdigit((unsigned char)p[4]) && isspace((unsigned > char)p[5])) > p += 5; > if (strlcat(s->replybuf, p, sizeof s->replybuf) >= > sizeof s->replybuf) > (void)strlcpy(s->replybuf, line, sizeof > s->replybuf); > Index: usr.sbin/smtpd/parse.y > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v > retrieving revision 1.276 > diff -u -p -u -r1.276 parse.y > --- usr.sbin/smtpd/parse.y 3 Feb 2020 15:41:22 -0000 1.276 > +++ usr.sbin/smtpd/parse.y 24 Feb 2020 18:19:51 -0000 > @@ -529,7 +529,7 @@ SMTP LIMIT limits_smtp > free($3); > YYERROR; > } > - if (isspace((int)*$3) || !isprint((int)*$3) || *$3== '@') { > + if (isspace((unsigned char)*$3) || !isprint((unsigned char)*$3) || *$3 > == '@') { > yyerror("sub-addr-delim uses invalid character"); > free($3); > YYERROR; > Index: usr.sbin/smtpd/smtp_client.c > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/smtp_client.c,v > retrieving revision 1.12 > diff -u -p -u -r1.12 smtp_client.c > --- usr.sbin/smtpd/smtp_client.c 10 Sep 2019 12:08:26 -0000 1.12 > +++ usr.sbin/smtpd/smtp_client.c 24 Feb 2020 18:21:43 -0000 > @@ -779,9 +779,10 @@ smtp_client_replycat(struct smtp_client > line += 3; > if (line[0]) { > line += 1; > - if (isdigit((int)line[0]) && line[1] == '.' && > - isdigit((int)line[2]) && line[3] == '.' && > - isdigit((int)line[4]) && isspace((int)line[5])) > + if (isdigit((unsigned char)line[0]) && line[1] == '.' && > + isdigit((unsigned char)line[2]) && line[3] == '.' && > + isdigit((unsigned char)line[4]) && > + isspace((unsigned char)line[5])) > line += 5; > } > } else > Index: usr.sbin/smtpd/util.c > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/util.c,v > retrieving revision 1.150 > diff -u -p -u -r1.150 util.c > --- usr.sbin/smtpd/util.c 3 Oct 2019 04:49:12 -0000 1.150 > +++ usr.sbin/smtpd/util.c 24 Feb 2020 19:17:12 -0000 > @@ -462,7 +462,7 @@ valid_domainpart(const char *s) > if (strlcpy(domain, p, sizeof domain) >= sizeof domain) > return 0; > > - c = strchr(domain, (int)']'); > + c = strchr(domain, ']'); > if (!c || c[1] != '\0') > return 0; > > @@ -489,7 +489,7 @@ valid_domainpart(const char *s) > return res_hnok(s); > } > > -#define LABELCHR(c) ((c) == '-' || (c) == '_' || isalpha((int)(c)) || > isdigit((int)(c))) > +#define LABELCHR(c) ((c) == '-' || (c) == '_' || isalpha((unsigned char)(c)) > || isdigit((unsigned char)(c))) > #define LABELMAX 63 > #define DNAMEMAX 253 > >