From: Jeremy Harris Date: Tue, 28 Feb 2017 23:57:36 +0000 (+0000) Subject: Coverity fixes X-Git-Tag: exim-4_89_RC7~1 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/c3cd3c84d80d4cb09f2a7474765e3ee393382af5 Coverity fixes (cherry picked from commit 59d9803955886f56f67e3ceff5632b704e4c5548) Signed-off-by: Phil Pennock --- diff --git a/src/src/dkim.c b/src/src/dkim.c index 2873eda53..f644fbfdd 100644 --- a/src/src/dkim.c +++ b/src/src/dkim.c @@ -571,7 +571,7 @@ while ((dkim_signing_domain = string_nextinlist(&dkim_domain, &sep, if (dkim_private_key_expanded[0] == '/') { - int privkey_fd = 0; + int privkey_fd, off = 0, len; /* Looks like a filename, load the private key. */ @@ -585,14 +585,21 @@ while ((dkim_signing_domain = string_nextinlist(&dkim_domain, &sep, goto bad; } - if (read(privkey_fd, big_buffer, big_buffer_size - 2) < 0) + do { - log_write(0, LOG_MAIN|LOG_PANIC, "unable to read private key file: %s", - dkim_private_key_expanded); - goto bad; + if ((len = read(privkey_fd, big_buffer + off, big_buffer_size - 2 - off)) < 0) + { + (void) close(privkey_fd); + log_write(0, LOG_MAIN|LOG_PANIC, "unable to read private key file: %s", + dkim_private_key_expanded); + goto bad; + } + off += len; } + while (len > 0); (void) close(privkey_fd); + big_buffer[off] = '\0'; dkim_private_key_expanded = big_buffer; } diff --git a/src/src/receive.c b/src/src/receive.c index ed2c57ba5..7980c324f 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -938,8 +938,11 @@ for(;;) that would need to be duplicated here. So we simply do some ungetc trickery. */ - fseek(fout, -1, SEEK_CUR); - if (fgetc(fout) == '\n') return END_DOT; + if (fout) + { + if (fseek(fout, -1, SEEK_CUR) < 0) return END_PROTOCOL; + if (fgetc(fout) == '\n') return END_DOT; + } if (linelength == -1) /* \r already seen (see below) */ { @@ -987,7 +990,7 @@ for(;;) else { message_size++; - if (fout != NULL && fputc('\n', fout) == EOF) return END_WERROR; + if (fout && fputc('\n', fout) == EOF) return END_WERROR; (void) cutthrough_put_nl(); if (ch == '\r') continue; /* don't write CR */ ch_state = MID_LINE;