git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TLS: PIPELINING under OpenSSL
[exim.git]
/
src
/
src
/
dkim_transport.c
diff --git
a/src/src/dkim_transport.c
b/src/src/dkim_transport.c
index 4538b36e3f9995d5822fbc27c84e294cd417b982..4d26f9291dba78cc3a75fa93e4eb8610257a5cd8 100644
(file)
--- a/
src/src/dkim_transport.c
+++ b/
src/src/dkim_transport.c
@@
-12,10
+12,6
@@
#ifndef DISABLE_DKIM /* rest of file */
#ifndef DISABLE_DKIM /* rest of file */
-#ifdef HAVE_LINUX_SENDFILE
-# include <sys/sendfile.h>
-#endif
-
static BOOL
dkt_sign_fail(struct ob_dkim * dkim, int * errp)
static BOOL
dkt_sign_fail(struct ob_dkim * dkim, int * errp)
@@
-38,14
+34,16
@@
if (dkim->dkim_strict)
return TRUE;
}
return TRUE;
}
+/* Send the file at in_fd down the output fd */
+
static BOOL
dkt_send_file(int out_fd, int in_fd, off_t off, size_t size)
{
static BOOL
dkt_send_file(int out_fd, int in_fd, off_t off, size_t size)
{
-DEBUG(D_transport) debug_printf("send file fd=%d size=%
d\n", out_fd, size - off
);
+DEBUG(D_transport) debug_printf("send file fd=%d size=%
u\n", out_fd, (unsigned)(size - off)
);
/*XXX should implement timeout, like transport_write_block_fd() ? */
/*XXX should implement timeout, like transport_write_block_fd() ? */
-#ifdef
HAVE_LINUX
_SENDFILE
+#ifdef
OS
_SENDFILE
/* We can use sendfile() to shove the file contents
to the socket. However only if we don't use TLS,
as then there's another layer of indirection
/* We can use sendfile() to shove the file contents
to the socket. However only if we don't use TLS,
as then there's another layer of indirection
@@
-55,7
+53,7
@@
if (tls_out.active != out_fd)
ssize_t copied = 0;
while(copied >= 0 && off < size)
ssize_t copied = 0;
while(copied >= 0 && off < size)
- copied = sendfile(out_fd, in_fd, &off, size - off);
+ copied =
os_
sendfile(out_fd, in_fd, &off, size - off);
if (copied < 0)
return FALSE;
}
if (copied < 0)
return FALSE;
}
@@
-67,10
+65,10
@@
else
int sread, wwritten;
/* Rewind file */
int sread, wwritten;
/* Rewind file */
-
lseek(in_fd, off, SEEK_SET)
;
+
if (lseek(in_fd, off, SEEK_SET) < 0) return FALSE
;
/* Send file down the original fd */
/* Send file down the original fd */
- while((sread = read(in_fd, deliver_out_buffer, DELIVER_OUT_BUFFER_SIZE)) >0)
+ while((sread = read(in_fd, deliver_out_buffer, DELIVER_OUT_BUFFER_SIZE)) >
0)
{
uschar * p = deliver_out_buffer;
/* write the chunk */
{
uschar * p = deliver_out_buffer;
/* write the chunk */
@@
-79,7
+77,7
@@
else
{
#ifdef SUPPORT_TLS
wwritten = tls_out.active == out_fd
{
#ifdef SUPPORT_TLS
wwritten = tls_out.active == out_fd
- ? tls_write(FALSE, p, sread)
+ ? tls_write(FALSE, p, sread
, FALSE
)
: write(out_fd, CS p, sread);
#else
wwritten = write(out_fd, CS p, sread);
: write(out_fd, CS p, sread);
#else
wwritten = write(out_fd, CS p, sread);
@@
-120,7
+118,7
@@
int save_fd = tctx->u.fd;
int save_options = tctx->options;
BOOL save_wireformat = spool_file_wireformat;
uschar * hdrs, * dkim_signature;
int save_options = tctx->options;
BOOL save_wireformat = spool_file_wireformat;
uschar * hdrs, * dkim_signature;
-int siglen, hsize;
+int siglen
= 0
, hsize;
const uschar * errstr;
BOOL rc;
const uschar * errstr;
BOOL rc;
@@
-164,7
+162,7
@@
temporarily set the marker for possible already-CRLF input. */
tctx->options &= ~topt_escape_headers;
spool_file_wireformat = TRUE;
transport_write_reset(0);
tctx->options &= ~topt_escape_headers;
spool_file_wireformat = TRUE;
transport_write_reset(0);
-if ( !write_chunk(tctx, dkim_signature, siglen)
+if (
siglen > 0 &&
!write_chunk(tctx, dkim_signature, siglen)
|| !write_chunk(tctx, hdrs, hsize))
return FALSE;
|| !write_chunk(tctx, hdrs, hsize))
return FALSE;
@@
-202,7
+200,7
@@
int dkim_fd;
int save_errno = 0;
BOOL rc;
uschar * dkim_spool_name, * dkim_signature;
int save_errno = 0;
BOOL rc;
uschar * dkim_spool_name, * dkim_signature;
-int sread = 0, wwritten = 0, siglen, options;
+int sread = 0, wwritten = 0, siglen
= 0
, options;
off_t k_file_size;
const uschar * errstr;
off_t k_file_size;
const uschar * errstr;
@@
-253,10
+251,14
@@
else if (!(rc = dkt_sign_fail(dkim, &save_errno)))
goto CLEANUP;
}
goto CLEANUP;
}
-#ifndef
HAVE_LINUX
_SENDFILE
+#ifndef
OS
_SENDFILE
if (options & topt_use_bdat)
#endif
if (options & topt_use_bdat)
#endif
- k_file_size = lseek(dkim_fd, 0, SEEK_END); /* Fetch file size */
+ if ((k_file_size = lseek(dkim_fd, 0, SEEK_END)) < 0)
+ {
+ *err = string_sprintf("dkim spoolfile seek: %s", strerror(errno));
+ goto CLEANUP;
+ }
if (options & topt_use_bdat)
{
if (options & topt_use_bdat)
{
@@
-292,7
+294,7
@@
if (!dkt_send_file(tctx->u.fd, dkim_fd, 0, k_file_size))
CLEANUP:
/* unlink -K file */
CLEANUP:
/* unlink -K file */
- (void)close(dkim_fd);
+
if (dkim_fd >= 0)
(void)close(dkim_fd);
Uunlink(dkim_spool_name);
errno = save_errno;
return rc;
Uunlink(dkim_spool_name);
errno = save_errno;
return rc;