From 3f77bd134b64c532748b83c3931df07058268b5e Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 26 Mar 2024 19:52:49 +0000 Subject: [PATCH] tidying --- src/exim_monitor/em_log.c | 10 ++++------ src/src/auths/cram_md5.c | 2 +- src/src/dbfn.c | 4 ++-- src/src/exim_dbmbuild.c | 6 +++--- src/src/functions.h | 6 ++++++ src/src/routers/manualroute.c | 4 ++-- src/src/routers/queryprogram.c | 2 +- src/src/search.c | 2 +- src/src/smtp_in.c | 9 ++++++--- src/src/smtp_out.c | 2 +- src/src/string.c | 2 +- src/src/tls-openssl.c | 3 ++- src/src/verify.c | 2 +- src/src/xclient.c | 2 +- 14 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/exim_monitor/em_log.c b/src/exim_monitor/em_log.c index fbcb6b1c0..49f649d7e 100644 --- a/src/exim_monitor/em_log.c +++ b/src/exim_monitor/em_log.c @@ -294,7 +294,7 @@ if (LOG != NULL) if ((p = Ustrstr(buffer, "==")) != NULL) { - queue_item *qq = find_queue(id, queue_noop, 0); + queue_item * qq = find_queue(id, queue_noop, 0); if (qq) { dest_item *d; @@ -302,14 +302,12 @@ if (LOG != NULL) p += 2; while (isspace(*p)) p++; q = p; - while (*p != 0 && !isspace(*p)) + while (*p && !isspace(*p)) { if (*p++ != '\"') continue; - while (*p != 0) - { + while (*p) if (*p == '\\') p += 2; - else if (*p++ == '\"') break; - } + else if (*p++ == '\"') break; } *p++ = 0; if ((r = strstric(q, qualify_domain, FALSE)) != NULL && diff --git a/src/src/auths/cram_md5.c b/src/src/auths/cram_md5.c index 8f00ee498..5817be7c9 100644 --- a/src/src/auths/cram_md5.c +++ b/src/src/auths/cram_md5.c @@ -198,7 +198,7 @@ The former is now the preferred variable; the latter is the original one. Then check that the remaining length is 32. */ auth_vars[0] = expand_nstring[1] = clear; -while (*clear && !isspace(*clear)) clear++; +Uskip_nonwhite(&clear); if (!isspace(*clear)) return FAIL; *clear++ = 0; diff --git a/src/src/dbfn.c b/src/src/dbfn.c index 13a3c2d66..389d1518e 100644 --- a/src/src/dbfn.c +++ b/src/src/dbfn.c @@ -544,8 +544,8 @@ while (Ufgets(buffer, 256, stdin) != NULL) Uskip_whitespace(&key); data = key; - while (*data && !isspace((uschar)*data)) data++; - *data++ = 0; + Uskip_nonwhite(&data); + *data++ = '\0'; Uskip_whitespace(&data); dbwait = (dbdata_wait *)(&structbuffer); diff --git a/src/src/exim_dbmbuild.c b/src/src/exim_dbmbuild.c index 9f5f2f042..bd24faa5b 100644 --- a/src/src/exim_dbmbuild.c +++ b/src/src/exim_dbmbuild.c @@ -379,7 +379,7 @@ while (Ufgets(line, max_insize, f) != NULL) else { keystart = s; - while (*s != 0 && *s != ':' && !isspace(*s)) s++; + while (*s && *s != ':' && !isspace(*s)) s++; exim_datum_size_set(&key, s - keystart + add_zero); } @@ -401,11 +401,11 @@ while (Ufgets(line, max_insize, f) != NULL) keybuffer[i] = 0; started = 1; - while (isspace(*s))s++; + while (isspace(*s)) s++; if (*s == ':') { s++; - while (isspace(*s))s++; + while (isspace(*s)) s++; } if (*s != 0) { diff --git a/src/src/functions.h b/src/src/functions.h index 0e657d7c4..d811c62a3 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -767,6 +767,12 @@ Return the next char as there's enough places using it to be useful. */ static inline uschar skip_whitespace(const uschar ** sp) { while (isspace(**sp)) (*sp)++; return **sp; } +/* Ditto, non-whitespace */ + +#define Uskip_nonwhite(sp) skip_nonwhite(CUSS sp) +static inline uschar skip_nonwhite(const uschar ** sp) +{ while (**sp && !isspace(**sp)) (*sp)++; return **sp; } + /******************************************************************************/ diff --git a/src/src/routers/manualroute.c b/src/src/routers/manualroute.c index ed497336b..ffd6eeaca 100644 --- a/src/src/routers/manualroute.c +++ b/src/src/routers/manualroute.c @@ -335,7 +335,7 @@ while (*options) unsigned n; const uschar * s = options; - while (*options && !isspace(*options)) options++; + Uskip_nonwhite(&options); n = options-s; if (Ustrncmp(s, "randomize", n) == 0) randomize = TRUE; @@ -369,7 +369,7 @@ while (*options) if (*options) { options++; - while (*options && isspace(*options)) options++; + Uskip_whitespace(&options); } } diff --git a/src/src/routers/queryprogram.c b/src/src/routers/queryprogram.c index 5f0f50cd9..39645cd23 100644 --- a/src/src/routers/queryprogram.c +++ b/src/src/routers/queryprogram.c @@ -365,7 +365,7 @@ DEBUG(D_route) debug_printf("command wrote: %s\n", buffer); rword = buffer; Uskip_whitespace(&rword); rdata = rword; -while (*rdata && !isspace(*rdata)) rdata++; +Uskip_nonwhite(&rdata); if (*rdata) *rdata++ = '\0'; /* The word must be a known yield name. If it is "REDIRECT", the rest of the diff --git a/src/src/search.c b/src/src/search.c index 168c25e6a..d0eb84b3b 100644 --- a/src/src/search.c +++ b/src/src/search.c @@ -247,7 +247,7 @@ if (mac_islookup(search_type, lookup_absfilequery)) if (*query == '/') { uschar * s = query; - while (*query && !isspace(*query)) query++; + Uskip_nonwhite(&query); *fnamep = string_copyn(s, query - s); Uskip_whitespace(&query); } diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 79176687d..70e4b95df 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -1946,6 +1946,9 @@ while (done <= 0) case HELP_CMD: case NOOP_CMD: case ETRN_CMD: +#ifdef EXPERIMENTAL_WELLKNOWN + case WELLKNOWN_CMD: +#endif bsmtp_transaction_linecount = receive_linecount; break; @@ -2991,8 +2994,8 @@ switch (where) if (where == ACL_WHERE_AUTH) /* avoid logging auth creds */ { - uschar * s; - for (s = smtp_cmd_data; *s && !isspace(*s); ) s++; + uschar * s = smtp_cmd_data; + Uskip_nonwhite(&s); lim = s - smtp_cmd_data; /* atop after method */ } what = string_sprintf("%s %.*s", acl_wherenames[where], lim, place); @@ -5694,7 +5697,7 @@ while (done <= 0) case TOO_MANY_NONMAIL_CMD: s = smtp_cmd_buffer; - while (*s && !isspace(*s)) s++; + Uskip_nonwhite(&s); incomplete_transaction_log(US"too many non-mail commands"); log_write(0, LOG_MAIN|LOG_REJECT, "SMTP call from %s dropped: too many " "nonmail commands (last was \"%.*s\")", host_and_ident(FALSE), diff --git a/src/src/smtp_out.c b/src/src/smtp_out.c index 888a0006e..a78b15fbd 100644 --- a/src/src/smtp_out.c +++ b/src/src/smtp_out.c @@ -709,7 +709,7 @@ if (format) { p += 5; Uskip_whitespace(&p); - while (!isspace(*p)) p++; + Uskip_nonwhite(&p); Uskip_whitespace(&p); } while (*p) *p++ = '*'; diff --git a/src/src/string.c b/src/src/string.c index af187c199..379be2035 100644 --- a/src/src/string.c +++ b/src/src/string.c @@ -649,7 +649,7 @@ uschar * t, * yield; /* First find the end of the string */ if (*s != '\"') - while (*s && !isspace(*s)) s++; + Uskip_nonwhite(&s); else { s++; diff --git a/src/src/tls-openssl.c b/src/src/tls-openssl.c index 64e8c711a..34612adea 100644 --- a/src/src/tls-openssl.c +++ b/src/src/tls-openssl.c @@ -5179,7 +5179,8 @@ for (uschar * s = exp; *s; /**/) return FALSE; } adding = *s++ == '+'; - for (end = s; *end && !isspace(*end); ) end++; + end = s; + Uskip_nonwhite(&end); item_parsed = tls_openssl_one_option_parse(string_copyn(s, end-s), &item); if (!item_parsed) { diff --git a/src/src/verify.c b/src/src/verify.c index 4f3bafb04..065deec41 100644 --- a/src/src/verify.c +++ b/src/src/verify.c @@ -3081,7 +3081,7 @@ if (iplookup) { filename = semicolon + 1; key = filename; - while (*key != 0 && !isspace(*key)) key++; + Uskip_nonwhite(&key); filename = string_copyn(filename, key - filename); Uskip_whitespace(&key); } diff --git a/src/src/xclient.c b/src/src/xclient.c index 2219cb027..fb9d95c5e 100644 --- a/src/src/xclient.c +++ b/src/src/xclient.c @@ -172,7 +172,7 @@ for (state = XCLIENT_SKIP_SPACES; *s; ) uschar * val; word = ++s; /* skip the = */ - while (*s && !isspace(*s)) s++; + Uskip_nonwhite(&s); len = s - word; DEBUG(D_transport) debug_printf(" XCLIENT: \tvalue %.*s\n", len, word); -- 2.30.2