From: Eric Allman Date: Fri, 19 Feb 1993 12:22:46 +0000 (-0800) Subject: move the meta-characters from C0 into C1 space X-Git-Tag: BSD-4_4-Snapshot-Development~3207 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/2bee003d3380d2e805660ddf49a0b39db076a151?hp=fe884dcbe1320378d2896038baa7cd6a2f3b4986 move the meta-characters from C0 into C1 space SCCS-vsn: usr.sbin/sendmail/src/usersmtp.c 6.10 SCCS-vsn: usr.sbin/sendmail/src/headers.c 6.7 SCCS-vsn: usr.sbin/sendmail/src/recipient.c 6.10 SCCS-vsn: usr.sbin/sendmail/src/macro.c 6.5 SCCS-vsn: usr.sbin/sendmail/src/convtime.c 6.2 SCCS-vsn: usr.sbin/sendmail/src/main.c 6.18 SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 6.15 SCCS-vsn: usr.sbin/sendmail/src/arpadate.c 6.6 SCCS-vsn: usr.sbin/sendmail/src/collect.c 6.4 SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 6.12 SCCS-vsn: usr.sbin/sendmail/src/savemail.c 6.6 SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 6.8 SCCS-vsn: usr.sbin/sendmail/src/util.c 6.6 SCCS-vsn: usr.sbin/sendmail/src/readcf.c 6.8 SCCS-vsn: usr.sbin/sendmail/src/deliver.c 6.17 SCCS-vsn: usr.sbin/sendmail/src/queue.c 6.12 SCCS-vsn: usr.sbin/sendmail/src/conf.c 6.15 SCCS-vsn: usr.sbin/sendmail/src/alias.c 6.11 SCCS-vsn: usr.sbin/sendmail/src/udb.c 6.7 SCCS-vsn: usr.sbin/sendmail/src/map.c 6.5 --- diff --git a/usr/src/usr.sbin/sendmail/src/alias.c b/usr/src/usr.sbin/sendmail/src/alias.c index 6a75f6d931..a6c8e3c971 100644 --- a/usr/src/usr.sbin/sendmail/src/alias.c +++ b/usr/src/usr.sbin/sendmail/src/alias.c @@ -29,15 +29,15 @@ ERROR: DBM is no longer supported -- use NDBM instead. #ifndef lint #ifdef NEWDB #ifdef NDBM -static char sccsid[] = "@(#)alias.c 6.10 (Berkeley) %G% (with NEWDB and NDBM)"; +static char sccsid[] = "@(#)alias.c 6.11 (Berkeley) %G% (with NEWDB and NDBM)"; #else -static char sccsid[] = "@(#)alias.c 6.10 (Berkeley) %G% (with NEWDB)"; +static char sccsid[] = "@(#)alias.c 6.11 (Berkeley) %G% (with NEWDB)"; #endif #else #ifdef NDBM -static char sccsid[] = "@(#)alias.c 6.10 (Berkeley) %G% (with NDBM)"; +static char sccsid[] = "@(#)alias.c 6.11 (Berkeley) %G% (with NDBM)"; #else -static char sccsid[] = "@(#)alias.c 6.10 (Berkeley) %G% (without NEWDB or NDBM)"; +static char sccsid[] = "@(#)alias.c 6.11 (Berkeley) %G% (without NEWDB or NDBM)"; #endif #endif #endif /* not lint */ @@ -665,7 +665,8 @@ readaliases(aliasfile, init, e) { extern char *DelimChar; - while (isspace(*p) || *p == ',') + while ((isascii(*p) && isspace(*p)) || + *p == ',') p++; if (*p == '\0') break; @@ -852,7 +853,7 @@ forward(user, sendq, e) define('u', user->q_user, e); define('h', user->q_host, e); if (ForwardPath == NULL) - ForwardPath = newstr("\001z/.forward"); + ForwardPath = newstr("\201z/.forward"); for (pp = ForwardPath; pp != NULL; pp = ep) { diff --git a/usr/src/usr.sbin/sendmail/src/arpadate.c b/usr/src/usr.sbin/sendmail/src/arpadate.c index 6e8a563e0f..d5d2a23082 100644 --- a/usr/src/usr.sbin/sendmail/src/arpadate.c +++ b/usr/src/usr.sbin/sendmail/src/arpadate.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)arpadate.c 6.5 (Berkeley) %G%"; +static char sccsid[] = "@(#)arpadate.c 6.6 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" @@ -321,7 +321,7 @@ arpatounix(s, e) /* now must have date */ tm.tm_mday = atoi(p); - while (isdigit((int) *p)) /* skip over date */ + while (isascii(*p) && isdigit(*p)) /* skip over date */ p++; p = nextatom(p); /* point to month name */ for (tm.tm_mon = 0; MonthList[tm.tm_mon]; tm.tm_mon++) @@ -362,28 +362,28 @@ arpatounix(s, e) tm.tm_year += ((gmt->tm_year - tm.tm_year) / 100) * 100; } } - while (isdigit((int) *p)) /* skip over year */ + while (isascii(*p) && isdigit(*p)) /* skip over year */ p++; - p = nextatom(p); /* hours */ + p = nextatom(p); /* hours */ tm.tm_hour = atoi(p); - while (isdigit((int) *p)) /* skip over hours */ + while (isascii(*p) && isdigit(*p)) /* skip over hours */ p++; - p = nextatom(p); /* colon */ + p = nextatom(p); /* colon */ if (*p == ':') p = nextatom(++p); - p = nextatom(p); /* minutes */ + p = nextatom(p); /* minutes */ tm.tm_min = atoi(p); - while (isdigit((int) *p)) /* skip over minutes */ + while (isascii(*p) && isdigit(*p)) /* skip over minutes */ p++; - p = nextatom(p); /* colon or zone */ - if (*p == ':') /* have seconds field */ + p = nextatom(p); /* colon or zone */ + if (*p == ':') /* have seconds field */ { p = nextatom(++p); tm.tm_sec = atoi(p); - while (isdigit((int) *p)) /* skip over seconds */ + while (isascii(*p) && isdigit(*p)) /* skip over seconds */ p++; } - p = nextatom(p); /* zone */ + p = nextatom(p); /* zone */ if (*p == '+') { diff --git a/usr/src/usr.sbin/sendmail/src/collect.c b/usr/src/usr.sbin/sendmail/src/collect.c index 2ccc03987f..37d9742795 100644 --- a/usr/src/usr.sbin/sendmail/src/collect.c +++ b/usr/src/usr.sbin/sendmail/src/collect.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)collect.c 6.3 (Berkeley) %G%"; +static char sccsid[] = "@(#)collect.c 6.4 (Berkeley) %G%"; #endif /* not lint */ # include @@ -408,7 +408,8 @@ eatfrom(fm, e) p++; while (*p == ' ') p++; - if (!isupper(*p) || p[3] != ' ' || p[13] != ':' || p[16] != ':') + if (!(isascii(*p) && isupper(*p)) || + p[3] != ' ' || p[13] != ':' || p[16] != ':') continue; /* we have a possible date */ diff --git a/usr/src/usr.sbin/sendmail/src/conf.c b/usr/src/usr.sbin/sendmail/src/conf.c index b1e434f6f2..c626655a77 100644 --- a/usr/src/usr.sbin/sendmail/src/conf.c +++ b/usr/src/usr.sbin/sendmail/src/conf.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)conf.c 6.14 (Berkeley) %G%"; +static char sccsid[] = "@(#)conf.c 6.15 (Berkeley) %G%"; #endif /* not lint */ # include @@ -268,7 +268,7 @@ host_map_init(map, mapname, args) for (;;) { - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; if (*p != '-') break; @@ -278,7 +278,7 @@ host_map_init(map, mapname, args) map->map_app = ++p; break; } - while (*p != '\0' && !isspace(*p)) + while (*p != '\0' && !(isascii(*p) && isspace(*p))) p++; if (*p != '\0') *p++ = '\0'; diff --git a/usr/src/usr.sbin/sendmail/src/convtime.c b/usr/src/usr.sbin/sendmail/src/convtime.c index dc449ef4c7..2074d37c9e 100644 --- a/usr/src/usr.sbin/sendmail/src/convtime.c +++ b/usr/src/usr.sbin/sendmail/src/convtime.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)convtime.c 6.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)convtime.c 6.2 (Berkeley) %G%"; #endif /* not lint */ # include @@ -46,7 +46,7 @@ convtime(p) while (*p != '\0') { t = 0; - while (isdigit(c = *p++)) + while (isascii(c = *p++) && isdigit(c)) t = t * 10 + (c - '0'); if (c == '\0') p--; diff --git a/usr/src/usr.sbin/sendmail/src/deliver.c b/usr/src/usr.sbin/sendmail/src/deliver.c index 35e2709546..e5a30f8985 100644 --- a/usr/src/usr.sbin/sendmail/src/deliver.c +++ b/usr/src/usr.sbin/sendmail/src/deliver.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)deliver.c 6.16 (Berkeley) %G%"; +static char sccsid[] = "@(#)deliver.c 6.17 (Berkeley) %G%"; #endif /* not lint */ #include "sendmail.h" @@ -170,10 +170,17 @@ deliver(e, firstto) for (mvp = m->m_argv; (p = *++mvp) != NULL; ) { - while ((p = strchr(p, '\001')) != NULL) - if (*++p == 'u') - break; - if (p != NULL) + /* can't use strchr here because of sign extension problems */ + while (*p != '\0') + { + if ((*p++ & 0377) == MACROEXPAND) + { + if (*p == 'u') + break; + } + } + + if (*p != '\0') break; /* this entry is safe -- go ahead and process it */ @@ -1185,7 +1192,7 @@ putfromline(fp, m, e) register MAILER *m; ENVELOPE *e; { - char *template = "\001l\n"; + char *template = "\201l\n"; char buf[MAXLINE]; extern char SentDate[]; @@ -1198,14 +1205,14 @@ putfromline(fp, m, e) char *bang; char xbuf[MAXLINE]; - expand("\001<", buf, &buf[sizeof buf - 1], e); + expand("\201<", buf, &buf[sizeof buf - 1], e); bang = strchr(buf, '!'); if (bang == NULL) syserr("No ! in UUCP! (%s)", buf); else { *bang++ = '\0'; - (void) sprintf(xbuf, "From %s \001d remote from %s\n", bang, buf); + (void) sprintf(xbuf, "From %s \201d remote from %s\n", bang, buf); template = xbuf; } } @@ -1765,7 +1772,7 @@ hostsignature(m, host, e) #ifdef NAMED_BIND if (myhostbuf[0] == '\0') - expand("\001j", myhostbuf, &myhostbuf[sizeof myhostbuf - 1], e); + expand("\201j", myhostbuf, &myhostbuf[sizeof myhostbuf - 1], e); nmx = getmxrr(host, mxhosts, myhostbuf, &rcode); if (nmx <= 0) diff --git a/usr/src/usr.sbin/sendmail/src/headers.c b/usr/src/usr.sbin/sendmail/src/headers.c index ecdcd3be31..01152e69a2 100644 --- a/usr/src/usr.sbin/sendmail/src/headers.c +++ b/usr/src/usr.sbin/sendmail/src/headers.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)headers.c 6.6 (Berkeley) %G%"; +static char sccsid[] = "@(#)headers.c 6.7 (Berkeley) %G%"; #endif /* not lint */ # include @@ -78,7 +78,7 @@ chompheader(line, def, e) return (0); } fvalue = &p[1]; - while (isspace(*--p)) + while (isascii(*--p) && isspace(*p)) continue; *++p = '\0'; makelower(fname); @@ -264,7 +264,7 @@ isheader(s) s++; /* following technically violates RFC822 */ - while (isspace(*s)) + while (isascii(*s) && isspace(*s)) s++; return (*s == ':'); @@ -484,7 +484,7 @@ crackaddr(addr) printf("crackaddr(%s)\n", addr); /* strip leading spaces */ - while (*addr != '\0' && isspace(*addr)) + while (*addr != '\0' && isascii(*addr) && isspace(*addr)) addr++; /* @@ -606,7 +606,7 @@ crackaddr(addr) /* back up over the '<' and any spaces */ --p; - while (isspace(*--p)) + while (isascii(*--p) && isspace(*p)) continue; p++; } @@ -662,7 +662,7 @@ crackaddr(addr) putg: if (copylev <= 0 && !putgmac) { - *bp++ = '\001'; + *bp++ = MACROEXPAND; *bp++ = 'g'; putgmac = TRUE; } @@ -833,7 +833,7 @@ commaize(h, p, fp, oldstyle, m, e) */ /* find end of name */ - while (isspace(*p) || *p == ',') + while ((isascii(*p) && isspace(*p)) || *p == ',') p++; name = p; for (;;) @@ -848,7 +848,7 @@ commaize(h, p, fp, oldstyle, m, e) /* look to see if we have an at sign */ oldp = p; - while (*p != '\0' && isspace(*p)) + while (*p != '\0' && isascii(*p) && isspace(*p)) p++; if (*p != '@' && !isatword(p)) @@ -857,13 +857,14 @@ commaize(h, p, fp, oldstyle, m, e) break; } p += *p == '@' ? 1 : 2; - while (*p != '\0' && isspace(*p)) + while (*p != '\0' && isascii(*p) && isspace(*p)) p++; } /* at the end of one complete name */ /* strip off trailing white space */ - while (p >= name && (isspace(*p) || *p == ',' || *p == '\0')) + while (p >= name && + ((isascii(*p) && isspace(*p)) || *p == ',' || *p == '\0')) p--; if (++p == name) continue; @@ -933,7 +934,7 @@ isatword(p) extern char lower(); if (lower(p[0]) == 'a' && lower(p[1]) == 't' && - p[2] != '\0' && isspace(p[2])) + p[2] != '\0' && isascii(p[2]) && isspace(p[2])) return (TRUE); return (FALSE); } diff --git a/usr/src/usr.sbin/sendmail/src/macro.c b/usr/src/usr.sbin/sendmail/src/macro.c index b0baa322ac..79077d69a8 100644 --- a/usr/src/usr.sbin/sendmail/src/macro.c +++ b/usr/src/usr.sbin/sendmail/src/macro.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)macro.c 6.4 (Berkeley) %G%"; +static char sccsid[] = "@(#)macro.c 6.5 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" @@ -67,7 +67,7 @@ expand(s, buf, buflim, e) q = NULL; c = *s; - switch (c) + switch (c & 0377) { case CONDIF: /* see if var set */ c = *++s; @@ -89,7 +89,7 @@ expand(s, buf, buflim, e) iflev--; continue; - case '\001': /* macro interpolation */ + case MACROEXPAND: /* macro interpolation */ c = *++s; q = macvalue(c & 0177, e); if (q == NULL) @@ -110,7 +110,8 @@ expand(s, buf, buflim, e) /* copy to end of q or max space remaining in buf */ while ((c = *q++) != '\0' && xp < &xbuf[sizeof xbuf - 1]) { - if (iscntrl(c) && !isspace(c)) + /* check for any sendmail metacharacters */ + if ((c & 0340) == 0200) recurse = TRUE; *xp++ = c; } diff --git a/usr/src/usr.sbin/sendmail/src/main.c b/usr/src/usr.sbin/sendmail/src/main.c index a4d9136c63..75fd124bb9 100644 --- a/usr/src/usr.sbin/sendmail/src/main.c +++ b/usr/src/usr.sbin/sendmail/src/main.c @@ -13,7 +13,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)main.c 6.17 (Berkeley) %G%"; +static char sccsid[] = "@(#)main.c 6.18 (Berkeley) %G%"; #endif /* not lint */ #define _DEFINE @@ -727,10 +727,10 @@ main(argc, argv, envp) printf("> %s", buf); if (buf[0] == '#') continue; - for (p = buf; isspace(*p); p++) + for (p = buf; isascii(*p) && isspace(*p); p++) continue; q = p; - while (*p != '\0' && !isspace(*p)) + while (*p != '\0' && !(isascii(*p) && isspace(*p))) p++; if (*p == '\0') { diff --git a/usr/src/usr.sbin/sendmail/src/map.c b/usr/src/usr.sbin/sendmail/src/map.c index f0ab32e021..f22cfc0492 100644 --- a/usr/src/usr.sbin/sendmail/src/map.c +++ b/usr/src/usr.sbin/sendmail/src/map.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)map.c 6.4 (Berkeley) %G%"; +static char sccsid[] = "@(#)map.c 6.5 (Berkeley) %G%"; #endif /* not lint */ #include "sendmail.h" @@ -100,7 +100,7 @@ dbm_map_lookup(map, buf, bufsiz, av) register char *p; for (p = buf; *p != '\0'; p++) - if (isupper(*p)) + if (isascii(*p) && isupper(*p)) *p = tolower(*p); } if (bitset(MF_INCLNULL, map->map_flags)) @@ -241,7 +241,7 @@ db_map_lookup(map, buf, bufsiz, av) register char *p; for (p = buf; *p != '\0'; p++) - if (isupper(*p)) + if (isascii(*p) && isupper(*p)) *p = tolower(*p); } if (bitset(MF_INCLNULL, map->map_flags)) @@ -278,7 +278,7 @@ map_parseargs(map, pp) for (;;) { - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; if (*p != '-') break; @@ -308,7 +308,7 @@ map_parseargs(map, pp) map->map_domain = ++p; break; } - while (*p != '\0' && !isspace(*p)) + while (*p != '\0' && !(isascii(*p) && isspace(*p))) p++; if (*p != '\0') *p++ = 0; @@ -321,7 +321,7 @@ map_parseargs(map, pp) if (*p == '\0') return NULL; map->map_file = p; - while (*p != '\0' && !isspace(*p)) + while (*p != '\0' && !(isascii(*p) && isspace(*p))) p++; if (*p != '\0') *p++ = '\0'; @@ -408,7 +408,7 @@ nis_map_lookup(map, buf, bufsiz, av) register char *p; for (p = buf; *p != '\0'; p++) - if (isupper(*p)) + if (isascii(*p) && isupper(*p)) *p = tolower(*p); } if (yp_match(map->map_domain, map->map_file, buf, strlen(buf) + 1, @@ -472,7 +472,7 @@ map_rewrite(s, slen, buf, buflen, av) c = '%'; if (c == '%') goto pushc; - if (!isdigit(c)) + if (!(isascii(c) && isdigit(c))) { *bp++ = '%'; goto pushc; diff --git a/usr/src/usr.sbin/sendmail/src/parseaddr.c b/usr/src/usr.sbin/sendmail/src/parseaddr.c index a4e2d252b9..b3f179a8ed 100644 --- a/usr/src/usr.sbin/sendmail/src/parseaddr.c +++ b/usr/src/usr.sbin/sendmail/src/parseaddr.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)parseaddr.c 6.14 (Berkeley) %G%"; +static char sccsid[] = "@(#)parseaddr.c 6.15 (Berkeley) %G%"; #endif /* not lint */ #include "sendmail.h" @@ -64,7 +64,7 @@ char *DelimChar; /* set to point to the delimiter */ */ /* following delimiters are inherent to the internal algorithms */ -# define DELIMCHARS "\001()<>,;\\\"\r\n" /* word delimiters */ +# define DELIMCHARS "\201()<>,;\\\"\r\n" /* word delimiters */ ADDRESS * parseaddr(addr, a, copyf, delim, e) @@ -128,7 +128,7 @@ parseaddr(addr, a, copyf, delim, e) ** See if we resolved to a real mailer. */ - if (pvp[0][0] != CANONNET) + if ((pvp[0][0] & 0377) != CANONNET) { setstat(EX_USAGE); usrerr("cannot resolve name"); @@ -179,8 +179,7 @@ invalidaddr(addr) { for (; *addr != '\0'; addr++) { - if (!isascii((int) *addr & 0377) || - !iscntrl(*addr) || isspace(*addr)) + if ((*addr & 0340) != 0200) continue; setstat(EX_USAGE); usrerr("Address contained invalid control characters"); @@ -508,7 +507,7 @@ prescan(addr, delim, pvpbuf) } anglecnt--; } - else if (delim == ' ' && isspace(c)) + else if (delim == ' ' && isascii(c) && isspace(c)) c = ' '; else if (c == ':' && !CurEnv->e_oldstyle) { @@ -587,7 +586,7 @@ prescan(addr, delim, pvpbuf) static int toktype(c) - register char c; + register int c; { static char buf[50]; static bool firstime = TRUE; @@ -595,9 +594,10 @@ toktype(c) if (firstime) { firstime = FALSE; - expand("\001o", buf, &buf[sizeof buf - 1], CurEnv); + expand("\201o", buf, &buf[sizeof buf - 1], CurEnv); (void) strcat(buf, DELIMCHARS); } + c &= 0377; if (c == MATCHCLASS || c == MATCHREPL || c == MATCHNCLASS) return (ONE); #ifdef MACVALUE @@ -606,11 +606,13 @@ toktype(c) #endif /* MACVALUE */ if (c == '"') return (QST); + if ((c & 0340) == 0200) + return (OPR); if (!isascii(c)) return (ATM); if (isspace(c) || c == ')') return (SPC); - if (iscntrl(c) || strchr(buf, c) != NULL) + if (strchr(buf, c) != NULL) return (OPR); return (ATM); } @@ -1113,18 +1115,18 @@ backup: } rp = *rvp; - if (*rp == CANONUSER) + if ((*rp & 0377) == CANONUSER) { rvp++; rwr = rwr->r_next; nmatches = 0; } - else if (*rp == CANONHOST) + else if ((*rp & 0377) == CANONHOST) { rvp++; rwr = NULL; } - else if (*rp == CANONNET) + else if ((*rp & 0377) == CANONNET) rwr = NULL; /* substitute */ @@ -1220,7 +1222,8 @@ backup: char begintype; char db = '\0'; - if (**rvp != HOSTBEGIN && **rvp != LOOKUPBEGIN) + if ((**rvp & 0377) != HOSTBEGIN && + (**rvp & 0377) != LOOKUPBEGIN) continue; /* @@ -1232,7 +1235,7 @@ backup: begintype = **rvp; hbrvp = rvp; ubrvp = NULL; - if (**rvp == HOSTBEGIN) + if ((**rvp & 0377) == HOSTBEGIN) { endtoken = HOSTEND; mapname = "host"; @@ -1252,9 +1255,9 @@ backup: arg_rvp = argvect; xpvp = NULL; replac = pvpbuf; - while (*rvp != NULL && **rvp != endtoken) + while (*rvp != NULL && (**rvp & 0377) != endtoken) { - int nodetype = **rvp; + int nodetype = **rvp & 0377; if (nodetype != CANONHOST && nodetype != CANONUSER) { @@ -1486,11 +1489,11 @@ buildaddr(tv, a) tv++; if (!strcasecmp(*tv, "error")) { - if (**++tv == CANONHOST) + if ((**++tv & 0377) == CANONHOST) { register struct errcodes *ep; - if (isdigit(**++tv)) + if (isascii(**++tv) && isdigit(**tv)) { setstat(atoi(*tv)); } @@ -1510,7 +1513,7 @@ buildaddr(tv, a) (void) strcat(buf, " "); (void) strcat(buf, *tv); } - if (**tv != CANONUSER) + if ((**tv & 0377) != CANONUSER) syserr("buildaddr: error: no user"); while (*++tv != NULL) { @@ -1581,7 +1584,7 @@ buildaddr(tv, a) } /* figure out the user */ - if (*tv == NULL || **tv != CANONUSER) + if (*tv == NULL || (**tv & 0377) != CANONUSER) { syserr("buildaddr: no user"); return (NULL); @@ -1839,7 +1842,7 @@ remotename(name, m, senderaddress, header, canonical, e) */ if (canonical || bitnset(M_NOCOMMENT, m->m_flags)) - fancy = "\001g"; + fancy = "\201g"; else fancy = crackaddr(name); @@ -2010,7 +2013,7 @@ maplocaluser(a, sendq, e) return; rewrite(pvp, 5); - if (pvp[0] == NULL || pvp[0][0] != CANONNET) + if (pvp[0] == NULL || (pvp[0][0] & 0377) != CANONNET) return; /* if non-null, mailer destination specified -- has it changed? */ diff --git a/usr/src/usr.sbin/sendmail/src/queue.c b/usr/src/usr.sbin/sendmail/src/queue.c index 653a98d367..77ae272065 100644 --- a/usr/src/usr.sbin/sendmail/src/queue.c +++ b/usr/src/usr.sbin/sendmail/src/queue.c @@ -10,9 +10,9 @@ #ifndef lint #ifdef QUEUE -static char sccsid[] = "@(#)queue.c 6.11 (Berkeley) %G% (with queueing)"; +static char sccsid[] = "@(#)queue.c 6.12 (Berkeley) %G% (with queueing)"; #else -static char sccsid[] = "@(#)queue.c 6.11 (Berkeley) %G% (without queueing)"; +static char sccsid[] = "@(#)queue.c 6.12 (Berkeley) %G% (without queueing)"; #endif #endif /* not lint */ @@ -263,7 +263,7 @@ queueup(e, queueall, announce) nullmailer.m_se_rwset = nullmailer.m_sh_rwset = -1; nullmailer.m_eol = "\n"; - define('g', "\001f", e); + define('g', "\201f", e); for (h = e->e_header; h != NULL; h = h->h_link) { extern bool bitzerop(); diff --git a/usr/src/usr.sbin/sendmail/src/readcf.c b/usr/src/usr.sbin/sendmail/src/readcf.c index c1b55c3314..cb1304ea35 100644 --- a/usr/src/usr.sbin/sendmail/src/readcf.c +++ b/usr/src/usr.sbin/sendmail/src/readcf.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)readcf.c 6.7 (Berkeley) %G%"; +static char sccsid[] = "@(#)readcf.c 6.8 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" @@ -139,7 +139,7 @@ readcf(cfname) continue; } - /* map $ into \001 (ASCII SOH) for macro expansion */ + /* map $ into \201 for macro expansion */ for (p = bp; *p != '\0'; p++) { if (*p == '#' && p > bp && ConfigLevel >= 3) @@ -147,9 +147,9 @@ readcf(cfname) /* this is an on-line comment */ register char *e; - switch (*--p) + switch (*--p & 0377) { - case '\001': + case MACROEXPAND: /* it's from $# -- let it go through */ p++; break; @@ -161,7 +161,7 @@ readcf(cfname) default: /* delete preceeding white space */ - while (isspace(*p) && p > bp) + while (isascii(*p) && isspace(*p) && p > bp) p--; if ((e = strchr(++p, '\n')) != NULL) (void) strcpy(p, e); @@ -183,7 +183,7 @@ readcf(cfname) } /* convert to macro expansion character */ - *p = '\001'; + *p = MACROEXPAND; } /* interpret this line */ @@ -230,7 +230,7 @@ readcf(cfname) /* count the number of fuzzy matches in LHS */ for (ap = rwp->r_lhs; *ap != NULL; ap++) { - switch (**ap) + switch (**ap & 0377) { case MATCHZANY: case MATCHANY: @@ -263,7 +263,7 @@ readcf(cfname) nfuzzy += '0'; for (ap = rwp->r_rhs; *ap != NULL; ap++) { - if (**ap != MATCHREPL) + if ((**ap & 0377) != MATCHREPL) continue; if ((*ap)[1] <= '0' || (*ap)[1] > nfuzzy) { @@ -300,14 +300,16 @@ readcf(cfname) if (bp[0] == 'F') { /* read from file */ - for (p = &bp[2]; *p != '\0' && !isspace(*p); p++) + for (p = &bp[2]; + *p != '\0' && !(isascii(*p) && isspace(*p)); + p++) continue; if (*p == '\0') p = "%s"; else { *p = '\0'; - while (isspace(*++p)) + while (isascii(*++p) && isspace(*p)) continue; } fileclass(bp[1], &bp[2], p, safe); @@ -320,10 +322,10 @@ readcf(cfname) register char *wd; char delim; - while (*p != '\0' && isspace(*p)) + while (*p != '\0' && isascii(*p) && isspace(*p)) p++; wd = p; - while (*p != '\0' && !isspace(*p)) + while (*p != '\0' && !(isascii(*p) && isspace(*p))) p++; delim = *p; *p = '\0'; @@ -361,10 +363,10 @@ readcf(cfname) p = &bp[1]; while (*p != '\0') { - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; q = p; - while (*p != '\0' && !isspace(*p)) + while (*p != '\0' && !(isascii(*p) && isspace(*p))) p++; if (*p != '\0') *p++ = '\0'; @@ -505,14 +507,14 @@ fileclass(class, filename, fmt, safe) register char *q; /* strip leading spaces */ - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; if (*p == '\0') break; /* find the end of the word */ q = p; - while (*p != '\0' && !isspace(*p)) + while (*p != '\0' && !(isascii(*p) && isspace(*p))) p++; if (*p != '\0') *p++ = '\0'; @@ -567,7 +569,7 @@ makemailer(line) m->m_eol = "\n"; /* collect the mailer name */ - for (p = line; *p != '\0' && *p != ',' && !isspace(*p); p++) + for (p = line; *p != '\0' && *p != ',' && !(isascii(*p) && isspace(*p)); p++) continue; if (*p != '\0') *p++ = '\0'; @@ -576,7 +578,7 @@ makemailer(line) /* now scan through and assign info from the fields */ while (*p != '\0') { - while (*p != '\0' && (*p == ',' || isspace(*p))) + while (*p != '\0' && (*p == ',' || (isascii(*p) && isspace(*p)))) p++; /* p now points to field code */ @@ -588,7 +590,7 @@ makemailer(line) syserr("mailer %s: `=' expected", m->m_name); return; } - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; /* p now points to the field body */ @@ -603,7 +605,7 @@ makemailer(line) case 'F': /* flags */ for (; *p != '\0'; p++) - if (!isspace(*p)) + if (!(isascii(*p) && isspace(*p))) setbitn(*p, m->m_flags); break; @@ -779,9 +781,9 @@ makeargv(p) while (*p != '\0' && i < MAXPV) { q = p; - while (*p != '\0' && !isspace(*p)) + while (*p != '\0' && !(isascii(*p) && isspace(*p))) p++; - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) *p++ = '\0'; argv[i++] = newstr(q); } @@ -1028,7 +1030,7 @@ setoption(opt, val, sticky) p--; p++; q = p; - while (*p != '\0' && !isspace(*p)) + while (*p != '\0' && !(isascii(*p) && isspace(*p))) p++; if (*p != '\0') *p++ = '\0'; @@ -1222,32 +1224,32 @@ makemapentry(line) register STAB *map; STAB *class; - for (p = line; isspace(*p); p++) + for (p = line; isascii(*p) && isspace(*p); p++) continue; - if (!isalnum(*p)) + if (!(isascii(*p) && isalnum(*p))) { syserr("readcf: config K line: no map name"); return; } mapname = p; - while (isalnum(*++p)) + while (isascii(*++p) && isalnum(*p)) continue; if (*p != '\0') *p++ = '\0'; - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; - if (!isalnum(*p)) + if (!(isascii(*p) && isalnum(*p))) { syserr("readcf: config K line, map %s: no map class", mapname); return; } classname = p; - while (isalnum(*++p)) + while (isascii(*++p) && isalnum(*p)) continue; if (*p != '\0') *p++ = '\0'; - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; /* look up the class */ diff --git a/usr/src/usr.sbin/sendmail/src/recipient.c b/usr/src/usr.sbin/sendmail/src/recipient.c index 1126c48cc8..c034b9a109 100644 --- a/usr/src/usr.sbin/sendmail/src/recipient.c +++ b/usr/src/usr.sbin/sendmail/src/recipient.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)recipient.c 6.9 (Berkeley) %G%"; +static char sccsid[] = "@(#)recipient.c 6.10 (Berkeley) %G%"; #endif /* not lint */ # include @@ -88,7 +88,7 @@ sendto(list, copyf, ctladdr, qflags) extern char *DelimChar; /* defined in prescan */ /* parse the address */ - while (isspace(*p) || *p == ',') + while ((isascii(*p) && isspace(*p)) || *p == ',') p++; a = parseaddr(p, (ADDRESS *) NULL, 1, delimiter, e); p = DelimChar; diff --git a/usr/src/usr.sbin/sendmail/src/savemail.c b/usr/src/usr.sbin/sendmail/src/savemail.c index 1b6dadb92a..9caafea5d9 100644 --- a/usr/src/usr.sbin/sendmail/src/savemail.c +++ b/usr/src/usr.sbin/sendmail/src/savemail.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)savemail.c 6.5 (Berkeley) %G%"; +static char sccsid[] = "@(#)savemail.c 6.6 (Berkeley) %G%"; #endif /* not lint */ # include @@ -157,7 +157,7 @@ savemail(e) break; } - expand("\001n", buf, &buf[sizeof buf - 1], e); + expand("\201n", buf, &buf[sizeof buf - 1], e); printf("\r\nMessage from %s...\r\n", buf); printf("Errors occurred while sending mail.\r\n"); if (e->e_xfp != NULL) @@ -263,7 +263,7 @@ savemail(e) /* we have a home directory; open dead.letter */ define('z', p, e); - expand("\001z/dead.letter", buf, &buf[sizeof buf - 1], e); + expand("\201z/dead.letter", buf, &buf[sizeof buf - 1], e); Verbose = TRUE; message(Arpa_Info, "Saving message in %s", buf); Verbose = oldverb; @@ -377,10 +377,10 @@ returntosender(msg, returnq, sendbody, e) } SendBody = sendbody; - define('g', "\001f", e); - define('<', "\001f", e); + define('g', "\201f", e); + define('<', "\201f", e); ee = newenvelope(&errenvelope); - define('a', "\001b", ee); + define('a', "\201b", ee); ee->e_puthdr = putheader; ee->e_putbody = errbody; ee->e_flags |= EF_RESPONSE; @@ -404,7 +404,7 @@ returntosender(msg, returnq, sendbody, e) addheader("subject", buf, ee); /* fake up an address header for the from person */ - expand("\001n", buf, &buf[sizeof buf - 1], e); + expand("\201n", buf, &buf[sizeof buf - 1], e); ee->e_sender = ee->e_returnpath = newstr(buf); if (parseaddr(buf, &ee->e_from, -1, '\0', e) == NULL) { @@ -417,7 +417,7 @@ returntosender(msg, returnq, sendbody, e) /* push state into submessage */ CurEnv = ee; - define('f', "\001n", ee); + define('f', "\201n", ee); define('x', "Mail Delivery Subsystem", ee); eatheader(ee, FALSE); diff --git a/usr/src/usr.sbin/sendmail/src/sendmail.h b/usr/src/usr.sbin/sendmail/src/sendmail.h index 8df97a9064..5813f09f96 100644 --- a/usr/src/usr.sbin/sendmail/src/sendmail.h +++ b/usr/src/usr.sbin/sendmail/src/sendmail.h @@ -5,7 +5,7 @@ * * %sccs.include.redist.c% * - * @(#)sendmail.h 6.11 (Berkeley) %G% + * @(#)sendmail.h 6.12 (Berkeley) %G% */ /* @@ -15,7 +15,7 @@ # ifdef _DEFINE # define EXTERN # ifndef lint -static char SmailSccsId[] = "@(#)sendmail.h 6.11 %G%"; +static char SmailSccsId[] = "@(#)sendmail.h 6.12 %G%"; # endif lint # else /* _DEFINE */ # define EXTERN extern @@ -339,35 +339,36 @@ EXTERN struct rewrite *RewriteRules[MAXRWSETS]; */ /* left hand side items */ -# define MATCHZANY '\020' /* match zero or more tokens */ -# define MATCHANY '\021' /* match one or more tokens */ -# define MATCHONE '\022' /* match exactly one token */ -# define MATCHCLASS '\023' /* match one token in a class */ -# define MATCHNCLASS '\024' /* match anything not in class */ -# define MATCHREPL '\025' /* replacement on RHS for above */ +# define MATCHZANY 0220 /* match zero or more tokens */ +# define MATCHANY 0221 /* match one or more tokens */ +# define MATCHONE 0222 /* match exactly one token */ +# define MATCHCLASS 0223 /* match one token in a class */ +# define MATCHNCLASS 0224 /* match anything not in class */ +# define MATCHREPL 0225 /* replacement on RHS for above */ # define MATCHLOOKUP '\035' /* look up and replace a sequence */ # define MATCHELOOKUP '\036' /* end of the sequence */ /* right hand side items */ -# define CANONNET '\026' /* canonical net, next token */ -# define CANONHOST '\027' /* canonical host, next token */ -# define CANONUSER '\030' /* canonical user, next N tokens */ -# define CALLSUBR '\031' /* call another rewriting set */ +# define CANONNET 0226 /* canonical net, next token */ +# define CANONHOST 0227 /* canonical host, next token */ +# define CANONUSER 0230 /* canonical user, next N tokens */ +# define CALLSUBR 0231 /* call another rewriting set */ /* conditionals in macros */ -# define CONDIF '\032' /* conditional if-then */ -# define CONDELSE '\033' /* conditional else */ -# define CONDFI '\034' /* conditional fi */ +# define CONDIF 0232 /* conditional if-then */ +# define CONDELSE 0233 /* conditional else */ +# define CONDFI 0234 /* conditional fi */ /* bracket characters for host name lookup */ -# define HOSTBEGIN '\035' /* hostname lookup begin */ -# define HOSTEND '\036' /* hostname lookup end */ +# define HOSTBEGIN 0235 /* hostname lookup begin */ +# define HOSTEND 0236 /* hostname lookup end */ /* bracket characters for generalized lookup */ -# define LOOKUPBEGIN '\005' /* generalized lookup begin */ -# define LOOKUPEND '\006' /* generalized lookup end */ +# define LOOKUPBEGIN 0205 /* generalized lookup begin */ +# define LOOKUPEND 0206 /* generalized lookup end */ -/* \001 is also reserved as the macro expansion character */ +/* macro substitution character */ +# define MACROEXPAND 0201 /* macro expansion */ /* external <==> internal mapping table */ struct metamac diff --git a/usr/src/usr.sbin/sendmail/src/srvrsmtp.c b/usr/src/usr.sbin/sendmail/src/srvrsmtp.c index 2f0b9fde46..31192f81d4 100644 --- a/usr/src/usr.sbin/sendmail/src/srvrsmtp.c +++ b/usr/src/usr.sbin/sendmail/src/srvrsmtp.c @@ -10,9 +10,9 @@ #ifndef lint #ifdef SMTP -static char sccsid[] = "@(#)srvrsmtp.c 6.7 (Berkeley) %G% (with SMTP)"; +static char sccsid[] = "@(#)srvrsmtp.c 6.8 (Berkeley) %G% (with SMTP)"; #else -static char sccsid[] = "@(#)srvrsmtp.c 6.7 (Berkeley) %G% (without SMTP)"; +static char sccsid[] = "@(#)srvrsmtp.c 6.8 (Berkeley) %G% (without SMTP)"; #endif #endif /* not lint */ @@ -112,7 +112,7 @@ smtp(e) RealHostName = MyHostName; CurHostName = RealHostName; setproctitle("srvrsmtp %s", CurHostName); - expand("\001e", inp, &inp[sizeof inp], e); + expand("\201e", inp, &inp[sizeof inp], e); message("220", "%s", inp); SmtpPhase = "startup"; sendinghost = NULL; @@ -155,15 +155,17 @@ smtp(e) fprintf(e->e_xfp, "<<< %s\n", inp); /* break off command */ - for (p = inp; isspace(*p); p++) + for (p = inp; isascii(*p) && isspace(*p); p++) continue; cmd = cmdbuf; - while (*p != '\0' && !isspace(*p) && cmd < &cmdbuf[sizeof cmdbuf - 2]) + while (*p != '\0' && + !(isascii(*p) && isspace(*p)) && + cmd < &cmdbuf[sizeof cmdbuf - 2]) *cmd++ = *p++; *cmd = '\0'; /* throw away leading whitespace */ - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; /* decode command */ @@ -455,14 +457,14 @@ skipword(p, w) register char *q; /* find beginning of word */ - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; q = p; /* find end of word */ - while (*p != '\0' && *p != ':' && !isspace(*p)) + while (*p != '\0' && *p != ':' && !(isascii(*p) && isspace(*p))) p++; - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) *p++ = '\0'; if (*p != ':') { @@ -472,7 +474,7 @@ skipword(p, w) return (NULL); } *p++ = '\0'; - while (isspace(*p)) + while (isascii(*p) && isspace(*p)) p++; /* see if the input word matches desired word */ diff --git a/usr/src/usr.sbin/sendmail/src/udb.c b/usr/src/usr.sbin/sendmail/src/udb.c index 28e6360617..00d8aa4fd2 100644 --- a/usr/src/usr.sbin/sendmail/src/udb.c +++ b/usr/src/usr.sbin/sendmail/src/udb.c @@ -8,9 +8,9 @@ #ifndef lint #ifdef USERDB -static char sccsid [] = "@(#)udb.c 6.6 (Berkeley) %G% (with USERDB)"; +static char sccsid [] = "@(#)udb.c 6.7 (Berkeley) %G% (with USERDB)"; #else -static char sccsid [] = "@(#)udb.c 6.6 (Berkeley) %G% (without USERDB)"; +static char sccsid [] = "@(#)udb.c 6.7 (Berkeley) %G% (without USERDB)"; #endif #endif @@ -606,7 +606,7 @@ _udb_parsespec(udbspec, opt, maxopts) { register char *p; - while (isspace(*spec)) + while (isascii(*spec) && isspace(*spec)) spec++; spec_end = strchr(spec, ':'); if (spec_end != NULL) diff --git a/usr/src/usr.sbin/sendmail/src/usersmtp.c b/usr/src/usr.sbin/sendmail/src/usersmtp.c index e857ac0463..d6555f0e1a 100644 --- a/usr/src/usr.sbin/sendmail/src/usersmtp.c +++ b/usr/src/usr.sbin/sendmail/src/usersmtp.c @@ -10,9 +10,9 @@ #ifndef lint #ifdef SMTP -static char sccsid[] = "@(#)usersmtp.c 6.9 (Berkeley) %G% (with SMTP)"; +static char sccsid[] = "@(#)usersmtp.c 6.10 (Berkeley) %G% (with SMTP)"; #else -static char sccsid[] = "@(#)usersmtp.c 6.9 (Berkeley) %G% (without SMTP)"; +static char sccsid[] = "@(#)usersmtp.c 6.10 (Berkeley) %G% (without SMTP)"; #endif #endif /* not lint */ @@ -187,7 +187,7 @@ smtpmailfrom(m, mci, e) mci->mci_state = MCIS_ACTIVE; - expand("\001<", buf, &buf[sizeof buf - 1], e); + expand("\201<", buf, &buf[sizeof buf - 1], e); if (e->e_from.q_mailer == LocalMailer || !bitnset(M_FROMPATH, m->m_flags)) { @@ -545,7 +545,8 @@ reply(m, mci, e, timeout) nmessage(Arpa_Info, "%s", SmtpReplyBuffer); /* if continuation is required, we can go on */ - if (SmtpReplyBuffer[3] == '-' || !isdigit(SmtpReplyBuffer[0])) + if (SmtpReplyBuffer[3] == '-' || + !(isascii(SmtpReplyBuffer[0]) && isdigit(SmtpReplyBuffer[0]))) continue; /* decode the reply code */ diff --git a/usr/src/usr.sbin/sendmail/src/util.c b/usr/src/usr.sbin/sendmail/src/util.c index fc27a8e0b6..0f96505639 100644 --- a/usr/src/usr.sbin/sendmail/src/util.c +++ b/usr/src/usr.sbin/sendmail/src/util.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)util.c 6.5 (Berkeley) %G%"; +static char sccsid[] = "@(#)util.c 6.6 (Berkeley) %G%"; #endif /* not lint */ # include @@ -82,13 +82,13 @@ capitalize(s) for (;;) { - while (!isalpha(*s) && *s != '\0') + while (!(isascii(*s) && isalpha(*s)) && *s != '\0') *p++ = *s++; if (*s == '\0') break; *p++ = toupper(*s); s++; - while (isalpha(*s)) + while (isascii(*s) && isalpha(*s)) *p++ = *s++; } @@ -212,7 +212,7 @@ char lower(c) register char c; { - return(isascii(c) && isupper(c) ? tolower(c) : c); + return((isascii(c) && isupper(c)) ? tolower(c) : c); } /* ** XPUTS -- put string doing control escapes. @@ -230,7 +230,7 @@ lower(c) xputs(s) register char *s; { - register char c; + register int c; register struct metamac *mp; extern struct metamac MetaMacros[]; @@ -239,10 +239,25 @@ xputs(s) printf(""); return; } - while ((c = *s++) != '\0') + while ((c = (*s++ & 0377)) != '\0') { if (!isascii(c)) { + if (c == MATCHREPL || c == MACROEXPAND) + { + putchar('$'); + continue; + } + for (mp = MetaMacros; mp->metaname != '\0'; mp++) + { + if ((mp->metaval & 0377) == c) + { + printf("$%c", mp->metaname); + break; + } + } + if (mp->metaname != '\0') + continue; (void) putchar('\\'); c &= 0177; } @@ -251,20 +266,6 @@ xputs(s) putchar(c); continue; } - if (c == MATCHREPL || c == '\001') - { - putchar('$'); - continue; - } - for (mp = MetaMacros; mp->metaname != '\0'; mp++) - { - if (mp->metaval == c) - { - printf("$%c", mp->metaname); - c = '\0'; - break; - } - } /* wasn't a meta-macro -- find another way to print it */ switch (c)