From: Jeremy Harris Date: Sat, 8 Apr 2017 20:59:32 +0000 (+0100) Subject: tidying X-Git-Tag: exim-4_90_RC1~197 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=36d295f1bf078693127e1ad556603968767bd9ce;p=exim.git tidying --- diff --git a/src/src/acl.c b/src/src/acl.c index 7aa8c78ad..42e7d7a42 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -3530,7 +3530,7 @@ for (; cb != NULL; cb = cb->next) break; case ACLC_RECIPIENTS: - rc = match_address_list((const uschar *)addr->address, TRUE, TRUE, &arg, NULL, -1, 0, + rc = match_address_list(CUS addr->address, TRUE, TRUE, &arg, NULL, -1, 0, CUSS &recipient_data); break; @@ -3548,14 +3548,14 @@ for (; cb != NULL; cb = cb->next) { uschar *sdomain; sdomain = Ustrrchr(sender_address, '@'); - sdomain = (sdomain == NULL)? US"" : sdomain + 1; + sdomain = sdomain ? sdomain + 1 ? US""; rc = match_isinlist(sdomain, &arg, 0, &domainlist_anchor, sender_domain_cache, MCL_DOMAIN, TRUE, NULL); } break; case ACLC_SENDERS: - rc = match_address_list((const uschar *)sender_address, TRUE, TRUE, &arg, + rc = match_address_list(CUS sender_address, TRUE, TRUE, &arg, sender_address_cache, -1, 0, CUSS &sender_data); break; diff --git a/src/src/deliver.c b/src/src/deliver.c index 139ee8374..ca3b8abfb 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -4607,7 +4607,7 @@ for (delivery_count = 0; addr_remote; delivery_count++) predictable settings for each delivery process, so do something explicit here rather they rely on the fixed reset in the random number function. */ - random_seed = running_in_test_harness? 42 + 2*delivery_count : 0; + random_seed = running_in_test_harness ? 42 + 2*delivery_count : 0; /* Set close-on-exec on the pipe so that it doesn't get passed on to a new process that may be forked to do another delivery down the same @@ -6045,9 +6045,7 @@ spool if the message is deferred, and in any case there are casing complications for local addresses. */ if (process_recipients != RECIP_IGNORE) - { for (i = 0; i < recipients_count; i++) - { if (!tree_search(tree_nonrecipients, recipients_list[i].address)) { recipient_item *r = recipients_list + i; @@ -6163,8 +6161,6 @@ if (process_recipients != RECIP_IGNORE) } #endif } - } - } DEBUG(D_deliver) { @@ -6229,10 +6225,8 @@ while (addr_new) /* Loop until all addresses dealt with */ not exist. In both cases, dbm_file is NULL. */ if (!(dbm_file = dbfn_open(US"retry", O_RDONLY, &dbblock, FALSE))) - { DEBUG(D_deliver|D_retry|D_route|D_hints_lookup) debug_printf("no retry data available\n"); - } /* Scan the current batch of new addresses, to handle pipes, files and autoreplies, and determine which others are ready for routing. */ @@ -6624,7 +6618,6 @@ while (addr_new) /* Loop until all addresses dealt with */ if ((rc = match_isinlist(addr->domain, (const uschar **)&queue_domains, 0, &domainlist_anchor, addr->domain_cache, MCL_DOMAIN, TRUE, NULL)) != OK) - { if (rc == DEFER) { addr->basic_errno = ERRNO_LISTDEFER; @@ -6636,7 +6629,6 @@ while (addr_new) /* Loop until all addresses dealt with */ addr->next = okaddr; okaddr = addr; } - } else { addr->basic_errno = ERRNO_QUEUE_DOMAIN; @@ -6671,7 +6663,7 @@ while (addr_new) /* Loop until all addresses dealt with */ &addr_succeed, v_none)) == DEFER) retry_add_item(addr, addr->router->retry_use_local_part - ? string_sprintf("R:%s@%s", addr->local_part, addr->domain) + ? string_sprintf("R:%s@%s", addr->local_part, addr->domain) : string_sprintf("R:%s", addr->domain), 0); diff --git a/src/src/functions.h b/src/src/functions.h index d99e1ca40..a10b743c9 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -261,6 +261,7 @@ extern void malware_init(void); #endif extern int match_address_list(const uschar *, BOOL, BOOL, const uschar **, unsigned int *, int, int, const uschar **); +extern int match_address_list_basic(const uschar *, const uschar **, int); extern int match_check_list(const uschar **, int, tree_node **, unsigned int **, int(*)(void *, const uschar *, const uschar **, uschar **), void *, int, const uschar *, const uschar **); diff --git a/src/src/match.c b/src/src/match.c index fa42187dd..93777c6fe 100644 --- a/src/src/match.c +++ b/src/src/match.c @@ -1326,4 +1326,25 @@ return match_check_list(listptr, sep, &addresslist_anchor, &local_cache_bits, valueptr); } +/* Simpler version of match_address_list; always caseless, expanding, +no cache bits, no value-return. + +Arguments: + address address to test + listptr list to check against + sep separator character for the list; + may be 0 to get separator from the list; + may be UCHAR_MAX+1 for one-item list + +Returns: OK for a positive match, or end list after a negation; + FAIL for a negative match, or end list after non-negation; + DEFER if a lookup deferred +*/ + +int +match_address_list_basic(const uschar *address, const uschar **listptr, int sep) +{ +return match_address_list(address, TRUE, TRUE, listptr, NULL, -1, sep, NULL); +} + /* End of match.c */ diff --git a/src/src/receive.c b/src/src/receive.c index aaf9215e9..64a8d511c 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -84,12 +84,10 @@ receive_check_set_sender(uschar *newsender) { uschar *qnewsender; if (trusted_caller) return TRUE; -if (newsender == NULL || untrusted_set_sender == NULL) return FALSE; -qnewsender = (Ustrchr(newsender, '@') != NULL)? - newsender : string_sprintf("%s@%s", newsender, qualify_domain_sender); -return - match_address_list(qnewsender, TRUE, TRUE, CUSS &untrusted_set_sender, NULL, -1, - 0, NULL) == OK; +if (!newsender || !untrusted_set_sender) return FALSE; +qnewsender = Ustrchr(newsender, '@') + ? newsender : string_sprintf("%s@%s", newsender, qualify_domain_sender); +return match_address_list_basic(qnewsender, CUSS &untrusted_set_sender, 0) == OK; } diff --git a/src/src/retry.c b/src/src/retry.c index 364591bd0..abfeeb4fb 100644 --- a/src/src/retry.c +++ b/src/src/retry.c @@ -159,8 +159,7 @@ deliveries (so as to do it all in one go). The tree records addresses that have become unusable during this delivery process (i.e. those that will get put into the retry database when it is updated). */ -node = tree_search(tree_unusable, host_key); -if (node != NULL) +if ((node = tree_search(tree_unusable, host_key))) { DEBUG(D_transport|D_retry) debug_printf("found in tree of unusables\n"); host->status = (node->data.val > 255)? @@ -172,7 +171,7 @@ if (node != NULL) /* Open the retry database, giving up if there isn't one. Otherwise, search for the retry records, and then close the database again. */ -if ((dbm_file = dbfn_open(US"retry", O_RDONLY, &dbblock, FALSE)) == NULL) +if (!(dbm_file = dbfn_open(US"retry", O_RDONLY, &dbblock, FALSE))) { DEBUG(D_deliver|D_retry|D_hints_lookup) debug_printf("no retry data available\n"); @@ -184,7 +183,7 @@ dbfn_close(dbm_file); /* Ignore the data if it is too old - too long since it was written */ -if (host_retry_record == NULL) +if (!host_retry_record) { DEBUG(D_transport|D_retry) debug_printf("no host retry record\n"); } @@ -194,7 +193,7 @@ else if (now - host_retry_record->time_stamp > retry_data_expire) DEBUG(D_transport|D_retry) debug_printf("host retry record too old\n"); } -if (message_retry_record == NULL) +if (!message_retry_record) { DEBUG(D_transport|D_retry) debug_printf("no message retry record\n"); } @@ -211,7 +210,7 @@ address. Allow the delivery if it has. Otherwise set the appropriate unusable flag and return FALSE. Otherwise arrange to return TRUE if this is an expired host. */ -if (host_retry_record != NULL) +if (host_retry_record) { *retry_host_key = host_key; @@ -243,7 +242,7 @@ if (host_retry_record != NULL) for reaching its retry time (or forcing). If not, mark the host unusable, unless the ultimate address timeout has been reached. */ -if (message_retry_record != NULL) +if (message_retry_record) { *retry_message_key = message_key; if (now < message_retry_record->next_try && !deliver_force) @@ -295,6 +294,7 @@ retry_add_item(address_item *addr, uschar *key, int flags) { retry_item *rti = store_get(sizeof(retry_item)); host_item * host = addr->host_used; + rti->next = addr->retries; addr->retries = rti; rti->key = key; @@ -378,7 +378,7 @@ if (alternate) alternate = string_sprintf("*@%s", alternate); /* Scan the configured retry items. */ -for (yield = retries; yield != NULL; yield = yield->next) +for (yield = retries; yield; yield = yield->next) { const uschar *plist = yield->pattern; const uschar *slist = yield->senders; @@ -472,19 +472,19 @@ for (yield = retries; yield != NULL; yield = yield->next) /* If the "senders" condition is set, check it. Note that sender_address may be null during -brt checking, in which case we do not use this rule. */ - if (slist != NULL && (sender_address == NULL || - match_address_list(sender_address, TRUE, TRUE, &slist, NULL, -1, 0, - NULL) != OK)) + if ( slist + && ( !sender_address + || match_address_list_basic(sender_address, &slist, 0) != OK + ) ) continue; /* Check for a match between the address list item at the start of this retry rule and either the main or alternate keys. */ - if (match_address_list(key, TRUE, TRUE, &plist, NULL, -1, UCHAR_MAX+1, - NULL) == OK || - (alternate != NULL && - match_address_list(alternate, TRUE, TRUE, &plist, NULL, -1, - UCHAR_MAX+1, NULL) == OK)) + if ( match_address_list_basic(key, &plist, UCHAR_MAX+1) == OK + || ( alternate + && match_address_list_basic(alternate, &plist, UCHAR_MAX+1) == OK + ) ) break; } @@ -639,7 +639,6 @@ for (i = 0; i < 3; i++) } DEBUG(D_retry) - { if (rti->flags & rf_host) debug_printf("retry for %s (%s) = %s %d %d\n", rti->key, addr->domain, retry->pattern, retry->basic_errno, @@ -647,7 +646,6 @@ for (i = 0; i < 3; i++) else debug_printf("retry for %s = %s %d %d\n", rti->key, retry->pattern, retry->basic_errno, retry->more_errno); - } /* Set up the message for the database retry record. Because DBM records have a maximum data length, we enforce a limit. There isn't @@ -861,10 +859,8 @@ for (i = 0; i < 3; i++) timed_out = TRUE; } else - { DEBUG(D_retry) debug_printf("timed out but some hosts were skipped\n"); - } } /* Loop for an address and its parents */ /* If this is a deferred address, and retry processing was requested by diff --git a/src/src/transport.c b/src/src/transport.c index 974b786ad..ee5120663 100644 --- a/src/src/transport.c +++ b/src/src/transport.c @@ -1543,7 +1543,6 @@ Returns: nothing void transport_update_waiting(host_item *hostlist, uschar *tpname) { -uschar buffer[256]; const uschar *prevname = US""; host_item *host; open_db dbblock; @@ -1553,19 +1552,20 @@ DEBUG(D_transport) debug_printf("updating wait-%s database\n", tpname); /* Open the database for this transport */ -sprintf(CS buffer, "wait-%.200s", tpname); -dbm_file = dbfn_open(buffer, O_RDWR, &dbblock, TRUE); -if (dbm_file == NULL) return; +if (!(dbm_file = dbfn_open(string_sprintf("wait-%.200s", tpname), + O_RDWR, &dbblock, TRUE))) + return; /* Scan the list of hosts for which this message is waiting, and ensure that the message id is in each host record. */ -for (host = hostlist; host!= NULL; host = host->next) +for (host = hostlist; host; host = host->next) { BOOL already = FALSE; dbdata_wait *host_record; uschar *s; int i, host_length; + uschar buffer[256]; /* Skip if this is the same host as we just processed; otherwise remember the name for next time. */ @@ -1575,8 +1575,7 @@ for (host = hostlist; host!= NULL; host = host->next) /* Look up the host record; if there isn't one, make an empty one. */ - host_record = dbfn_read(dbm_file, host->name); - if (host_record == NULL) + if (!(host_record = dbfn_read(dbm_file, host->name))) { host_record = store_get(sizeof(dbdata_wait) + MESSAGE_ID_LENGTH); host_record->count = host_record->sequence = 0; @@ -1590,10 +1589,8 @@ for (host = hostlist; host!= NULL; host = host->next) for (s = host_record->text; s < host_record->text + host_length; s += MESSAGE_ID_LENGTH) - { if (Ustrncmp(s, message_id, MESSAGE_ID_LENGTH) == 0) { already = TRUE; break; } - } /* If we haven't found this message in the main record, search any continuation records that exist. */ @@ -1602,15 +1599,12 @@ for (host = hostlist; host!= NULL; host = host->next) { dbdata_wait *cont; sprintf(CS buffer, "%.200s:%d", host->name, i); - cont = dbfn_read(dbm_file, buffer); - if (cont != NULL) + if ((cont = dbfn_read(dbm_file, buffer))) { int clen = cont->count * MESSAGE_ID_LENGTH; for (s = cont->text; s < cont->text + clen; s += MESSAGE_ID_LENGTH) - { if (Ustrncmp(s, message_id, MESSAGE_ID_LENGTH) == 0) { already = TRUE; break; } - } } } @@ -1706,7 +1700,6 @@ dbdata_wait *host_record; int host_length; open_db dbblock; open_db *dbm_file; -uschar buffer[256]; int i; struct stat statbuf; @@ -1733,9 +1726,9 @@ if (local_message_max > 0 && continue_sequence >= local_message_max) /* Open the waiting information database. */ -sprintf(CS buffer, "wait-%.200s", transport_name); -dbm_file = dbfn_open(buffer, O_RDWR, &dbblock, TRUE); -if (dbm_file == NULL) return FALSE; +if (!(dbm_file = dbfn_open(string_sprintf("wait-%.200s", transport_name), + O_RDWR, &dbblock, TRUE))) + return FALSE; /* See if there is a record for this host; if not, there's nothing to do. */ @@ -1851,13 +1844,13 @@ while (1) } } -/* Jeremy: check for a continuation record, this code I do not know how to -test but the code should work */ + /* Check for a continuation record. */ while (host_length <= 0) { int i; dbdata_wait * newr = NULL; + uschar buffer[256]; /* Search for a continuation */ diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 14eb76921..a5f8665e1 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -2701,17 +2701,14 @@ set it up. This cannot be done until the identify of the host is known. */ if (tblock->filter_command) { - BOOL rc; - uschar fbuf[64]; - sprintf(CS fbuf, "%.50s transport", tblock->name); - rc = transport_set_up_command(&transport_filter_argv, tblock->filter_command, - TRUE, DEFER, addrlist, fbuf, NULL); transport_filter_timeout = tblock->filter_timeout; /* On failure, copy the error to all addresses, abandon the SMTP call, and yield ERROR. */ - if (!rc) + if (!transport_set_up_command(&transport_filter_argv, + tblock->filter_command, TRUE, DEFER, addrlist, + string_sprintf("%.50s transport", tblock->name), NULL)) { set_errno_nohost(addrlist->next, addrlist->basic_errno, addrlist->message, DEFER, FALSE); @@ -2730,6 +2727,7 @@ if (tblock->filter_command) } } +sx.first_addr = addrlist; /* For messages that have more than the maximum number of envelope recipients, we want to send several transactions down the same SMTP connection. (See @@ -2741,7 +2739,7 @@ transaction to handle. */ SEND_MESSAGE: sx.from_addr = return_path; -sx.first_addr = sx.sync_addr = addrlist; +sx.sync_addr = sx.first_addr; sx.ok = FALSE; sx.send_rset = TRUE; sx.completed_addr = FALSE;