From 7e0f91e957ac1ce17068463b4c715b02617956c3 Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 24 Feb 2020 23:54:27 +0000 Subject: Cast argument of ctype(3) macros to unsigned char, not int. Similar to a diff from Hiltjo Posthum. OK jung@ deraadt@ --- mta_session.c | 21 ++++++++++----------- parse.y | 4 ++-- smtp_client.c | 9 +++++---- util.c | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/mta_session.c b/mta_session.c index 3f855664..e109e662 100644 --- a/mta_session.c +++ b/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.132 2020/02/24 16:16:07 millert Exp $ */ +/* $OpenBSD: mta_session.c,v 1.133 2020/02/24 23:54:27 millert Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -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); diff --git a/parse.y b/parse.y index e3a02430..4d187f7a 100644 --- a/parse.y +++ b/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.276 2020/02/03 15:41:22 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.277 2020/02/24 23:54:27 millert Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -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; diff --git a/smtp_client.c b/smtp_client.c index 22e79890..528f48b7 100644 --- a/smtp_client.c +++ b/smtp_client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_client.c,v 1.12 2019/09/10 12:08:26 eric Exp $ */ +/* $OpenBSD: smtp_client.c,v 1.13 2020/02/24 23:54:27 millert Exp $ */ /* * Copyright (c) 2018 Eric Faurot @@ -779,9 +779,10 @@ smtp_client_replycat(struct smtp_client *proto, const char *line) 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 diff --git a/util.c b/util.c index f59ad1e4..fce97ee7 100644 --- a/util.c +++ b/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.150 2019/10/03 04:49:12 gilles Exp $ */ +/* $OpenBSD: util.c,v 1.151 2020/02/24 23:54:28 millert Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -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 -- cgit v1.2.3-59-g8ed1b