diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2017-02-06 13:07:42 +0000 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2017-02-24 15:38:50 +0000 |
commit | 2c0f3ea1858d9dafc8600f9d97bc6e57594c22d0 (patch) | |
tree | 313fd288d98257cfdbf14d46d1896de0692985a9 | |
parent | b83fa5fa89071dab0637c0e58ba8e5c1b829149b (diff) |
tidying
-rw-r--r-- | src/src/acl.c | 10 | ||||
-rw-r--r-- | src/src/daemon.c | 4 | ||||
-rw-r--r-- | src/src/deliver.c | 26 | ||||
-rw-r--r-- | src/src/expand.c | 8 | ||||
-rw-r--r-- | src/src/pdkim/pdkim.c | 26 | ||||
-rw-r--r-- | src/src/smtp_in.c | 84 | ||||
-rw-r--r-- | src/src/tree.c | 10 |
7 files changed, 80 insertions, 88 deletions
diff --git a/src/src/acl.c b/src/src/acl.c index 60fa97752..efab1d31e 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -4351,7 +4351,7 @@ switch (where) if (*--s && isdigit(*s) && *--s && isdigit(*s)) *user_msgptr = s; acl_temp_details = TRUE; } - else + else { HDEBUG(D_acl) debug_printf_indent("cutthrough defer; will spool\n"); rc = OK; @@ -4425,12 +4425,10 @@ Returns the pointer to variable's tree node */ tree_node * -acl_var_create(uschar *name) +acl_var_create(uschar * name) { -tree_node *node, **root; -root = (name[0] == 'c')? &acl_var_c : &acl_var_m; -node = tree_search(*root, name); -if (node == NULL) +tree_node * node, ** root = name[0] == 'c' ? &acl_var_c : &acl_var_m; +if (!(node = tree_search(*root, name))) { node = store_get(sizeof(tree_node) + Ustrlen(name)); Ustrcpy(node->name, name); diff --git a/src/src/daemon.c b/src/src/daemon.c index ea0c22262..e9ecbe7d6 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -542,9 +542,9 @@ if (pid == 0) DEBUG(D_receive) { int i; - if (sender_address != NULL) + if (sender_address) debug_printf("Sender: %s\n", sender_address); - if (recipients_list != NULL) + if (recipients_list) { debug_printf("Recipients:\n"); for (i = 0; i < recipients_count; i++) diff --git a/src/src/deliver.c b/src/src/deliver.c index c97874a2b..c416ebf3f 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -3238,7 +3238,7 @@ uschar *endptr = big_buffer; uschar *ptr = endptr; uschar *msg = p->msg; BOOL done = p->done; -BOOL unfinished = TRUE; +BOOL finished = FALSE; /* minimum size to read is header size including id, subid and length */ int required = PIPE_HEADER_SIZE; @@ -3271,7 +3271,7 @@ while (!done) There will be only one read if we get all the available data (i.e. don't fill the buffer completely). */ - if (remaining < required && unfinished) + if (remaining < required && !finished) { int len; int available = big_buffer_size - remaining; @@ -3301,11 +3301,11 @@ while (!done) /* If the length is zero (eof or no-more-data), just process what we already have. Note that if the process is still running and we have read all the data in the pipe (but less that "available") then we - won't read any more, as "unfinished" will get set FALSE. */ + won't read any more, as "finished" will get set. */ endptr += len; remaining += len; - unfinished = len == available; + finished = len != available; } /* If we are at the end of the available data, exit the loop. */ @@ -3326,8 +3326,8 @@ while (!done) } DEBUG(D_deliver) - debug_printf("header read id:%c,subid:%c,size:%s,required:%d,remaining:%d,unfinished:%d\n", - id, subid, header+2, required, remaining, unfinished); + debug_printf("header read id:%c,subid:%c,size:%s,required:%d,remaining:%d,finished:%d\n", + id, subid, header+2, required, remaining, finished); /* is there room for the dataset we want to read ? */ if (required > big_buffer_size - PIPE_HEADER_SIZE) @@ -3339,22 +3339,22 @@ while (!done) break; } - /* we wrote all datasets with atomic write() calls - remaining < required only happens if big_buffer was too small - to get all available data from pipe. unfinished has to be true - as well. */ + /* We wrote all datasets with atomic write() calls. Remaining < required only + happens if big_buffer was too small to get all available data from pipe; + finished has to be false as well. */ + if (remaining < required) { - if (unfinished) + if (!finished) continue; msg = string_sprintf("failed to read pipe from transport process " - "%d for transport %s: required size=%d > remaining size=%d and unfinished=false", + "%d for transport %s: required size=%d > remaining size=%d and finished=true", pid, addr->transport->driver_name, required, remaining); done = TRUE; break; } - /* step behind the header */ + /* Step past the header */ ptr += PIPE_HEADER_SIZE; /* Handle each possible type of item, assuming the complete item is diff --git a/src/src/expand.c b/src/src/expand.c index 55fb0b875..6257c28b7 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -6745,12 +6745,11 @@ while (*s != 0) case EOP_LOCAL_PART: case EOP_DOMAIN: { - uschar *error; + uschar * error; int start, end, domain; - uschar *t = parse_extract_address(sub, &error, &start, &end, &domain, + uschar * t = parse_extract_address(sub, &error, &start, &end, &domain, FALSE); - if (t != NULL) - { + if (t) if (c != EOP_DOMAIN) { if (c == EOP_LOCAL_PART && domain != 0) end = start + domain - 1; @@ -6761,7 +6760,6 @@ while (*s != 0) domain += start; yield = string_catn(yield, &size, &ptr, sub+domain, end-domain); } - } continue; } diff --git a/src/src/pdkim/pdkim.c b/src/src/pdkim/pdkim.c index 4c93de70d..f26b745af 100644 --- a/src/src/pdkim/pdkim.c +++ b/src/src/pdkim/pdkim.c @@ -416,7 +416,7 @@ return b64encode(b->data, b->len); static pdkim_signature * pdkim_parse_sig_header(pdkim_ctx *ctx, uschar * raw_hdr) { -pdkim_signature *sig ; +pdkim_signature * sig; uschar *p, *q; uschar * cur_tag = NULL; int ts = 0, tl = 0; uschar * cur_val = NULL; int vs = 0, vl = 0; @@ -931,28 +931,25 @@ return PDKIM_OK; #define DKIM_SIGNATURE_HEADERNAME "DKIM-Signature:" static int -pdkim_header_complete(pdkim_ctx *ctx) +pdkim_header_complete(pdkim_ctx * ctx) { +pdkim_signature * sig, * last_sig; + /* Special case: The last header can have an extra \r appended */ if ( (ctx->cur_header_len > 1) && (ctx->cur_header[(ctx->cur_header_len)-1] == '\r') ) --ctx->cur_header_len; ctx->cur_header[ctx->cur_header_len] = '\0'; -ctx->num_headers++; -if (ctx->num_headers > PDKIM_MAX_HEADERS) goto BAIL; +if (++ctx->num_headers > PDKIM_MAX_HEADERS) goto BAIL; /* SIGNING -------------------------------------------------------------- */ if (ctx->flags & PDKIM_MODE_SIGN) - { - pdkim_signature *sig; - for (sig = ctx->sig; sig; sig = sig->next) /* Traverse all signatures */ /* Add header to the signed headers list (in reverse order) */ sig->headers = pdkim_prepend_stringlist(sig->headers, ctx->cur_header); - } /* VERIFICATION ----------------------------------------------------------- */ /* DKIM-Signature: headers are added to the verification list */ @@ -962,15 +959,13 @@ else DEBUG(D_acl) { debug_printf("PDKIM >> raw hdr: "); - pdkim_quoteprint(CUS ctx->cur_header, Ustrlen(ctx->cur_header)); + pdkim_quoteprint(CUS ctx->cur_header, ctx->cur_header_len); } #endif if (strncasecmp(CCS ctx->cur_header, DKIM_SIGNATURE_HEADERNAME, Ustrlen(DKIM_SIGNATURE_HEADERNAME)) == 0) { - pdkim_signature * new_sig, * last_sig; - /* Create and chain new signature block. We could error-check for all required tags here, but prefer to create the internal sig and expicitly fail verification of it later. */ @@ -978,14 +973,14 @@ else DEBUG(D_acl) debug_printf( "PDKIM >> Found sig, trying to parse >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); - new_sig = pdkim_parse_sig_header(ctx, ctx->cur_header); + sig = pdkim_parse_sig_header(ctx, ctx->cur_header); if (!(last_sig = ctx->sig)) - ctx->sig = new_sig; + ctx->sig = sig; else { while (last_sig->next) last_sig = last_sig->next; - last_sig->next = new_sig; + last_sig->next = sig; } } @@ -994,8 +989,7 @@ else } BAIL: -*ctx->cur_header = '\0'; -ctx->cur_header_len = 0; /* leave buffer for reuse */ +ctx->cur_header[ctx->cur_header_len = 0] = '\0'; /* leave buffer for reuse */ return PDKIM_OK; } diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 4cda753e8..f0885b3a1 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -949,43 +949,45 @@ Return the amount read. static int swallow_until_crlf(int fd, uschar *base, int already, int capacity) { - uschar *to = base + already; - uschar *cr; - int have = 0; - int ret; - int last = 0; - - /* For "PROXY UNKNOWN\r\n" we, at time of writing, expect to have read - up through the \r; for the _normal_ case, we haven't yet seen the \r. */ - cr = memchr(base, '\r', already); - if (cr != NULL) - { - if ((cr - base) < already - 1) - { - /* \r and presumed \n already within what we have; probably not - actually proxy protocol, but abort cleanly. */ - return 0; - } - /* \r is last character read, just need one more. */ - last = 1; - } +uschar *to = base + already; +uschar *cr; +int have = 0; +int ret; +int last = 0; + +/* For "PROXY UNKNOWN\r\n" we, at time of writing, expect to have read +up through the \r; for the _normal_ case, we haven't yet seen the \r. */ - while (capacity > 0) +cr = memchr(base, '\r', already); +if (cr != NULL) + { + if ((cr - base) < already - 1) { - do { ret = recv(fd, to, 1, 0); } while (ret == -1 && errno == EINTR); - if (ret == -1) - return -1; - have++; - if (last) - return have; - if (*to == '\r') - last = 1; - capacity--; - to++; + /* \r and presumed \n already within what we have; probably not + actually proxy protocol, but abort cleanly. */ + return 0; } - // reached end without having room for a final newline, abort - errno = EOVERFLOW; - return -1; + /* \r is last character read, just need one more. */ + last = 1; + } + +while (capacity > 0) + { + do { ret = recv(fd, to, 1, 0); } while (ret == -1 && errno == EINTR); + if (ret == -1) + return -1; + have++; + if (last) + return have; + if (*to == '\r') + last = 1; + capacity--; + to++; + } + +/* reached end without having room for a final newline, abort */ +errno = EOVERFLOW; +return -1; } /************************************************* @@ -1093,9 +1095,9 @@ if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, CS &tv, sizeof(tv)) < 0) do { /* The inbound host was declared to be a Proxy Protocol host, so - don't do a PEEK into the data, actually slurp up enough to be - "safe". Can't take it all because TLS-on-connect clients follow - immediately with TLS handshake. */ + don't do a PEEK into the data, actually slurp up enough to be + "safe". Can't take it all because TLS-on-connect clients follow + immediately with TLS handshake. */ ret = recv(fd, &hdr, PROXY_INITIAL_READ, 0); } while (ret == -1 && errno == EINTR); @@ -1121,9 +1123,9 @@ if ((ret == PROXY_INITIAL_READ) && (memcmp(&hdr.v2, v2sig, sizeof(v2sig)) == 0)) ver = (hdr.v2.ver_cmd & 0xf0) >> 4; /* May 2014: haproxy combined the version and command into one byte to - allow two full bytes for the length field in order to proxy SSL - connections. SSL Proxy is not supported in this version of Exim, but - must still separate values here. */ + allow two full bytes for the length field in order to proxy SSL + connections. SSL Proxy is not supported in this version of Exim, but + must still separate values here. */ if (ver != 0x02) { @@ -1270,7 +1272,7 @@ else if (ret >= 8 && memcmp(hdr.v1.line, "PROXY", 5) == 0) DEBUG(D_receive) debug_printf("Detected PROXYv1 header\n"); DEBUG(D_receive) debug_printf("Bytes read not within PROXY header: %d\n", ret - size); /* Step through the string looking for the required fields. Ensure - strict adherence to required formatting, exit for any error. */ + strict adherence to required formatting, exit for any error. */ p += 5; if (!isspace(*(p++))) { diff --git a/src/src/tree.c b/src/src/tree.c index 72c084a6e..3b6c3603b 100644 --- a/src/src/tree.c +++ b/src/src/tree.c @@ -330,11 +330,11 @@ Returns: pointer to node, or NULL if not found tree_node * tree_search(tree_node *p, const uschar *name) { -while (p != NULL) +while (p) { int c = Ustrcmp(name, p->name); if (c == 0) return p; - p = (c < 0)? p->left : p->right; + p = c < 0 ? p->left : p->right; } return NULL; } @@ -355,10 +355,10 @@ Arguments: void tree_walk(tree_node *p, void (*f)(uschar*, uschar*, void*), void *ctx) { -if (p == NULL) return; +if (!p) return; f(p->name, p->data.ptr, ctx); -if (p->left != NULL) tree_walk(p->left, f, ctx); -if (p->right != NULL) tree_walk(p->right, f, ctx); +tree_walk(p->left, f, ctx); +tree_walk(p->right, f, ctx); } |