if (dkim_private_key_expanded[0] == '/')
{
- int privkey_fd = 0;
+ int privkey_fd, off = 0, len;
/* Looks like a filename, load the private key. */
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;
}
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) */
{
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;