X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/3b1a84c8e4f17494f98642278121df35caa37476..59d9803955886f56f67e3ceff5632b704e4c5548:/src/src/dkim.c?ds=sidebyside diff --git a/src/src/dkim.c b/src/src/dkim.c index a0a79a51a..f51021443 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; }