git://git.exim.org
/
exim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b4d6cfa
)
malware: fix ClamAV file send corking
author
Jeremy Harris
<jgh146exb@wizmail.org>
Sat, 16 Jan 2021 21:00:34 +0000
(21:00 +0000)
committer
Jeremy Harris
<jgh146exb@wizmail.org>
Sat, 16 Jan 2021 23:11:59 +0000
(23:11 +0000)
src/src/malware.c
patch
|
blob
|
history
diff --git
a/src/src/malware.c
b/src/src/malware.c
index b581a87524bd66bf36e01945f4cd600e99d6d68b..abe627ded3a7e537c61e32985068579236ec0472 100644
(file)
--- a/
src/src/malware.c
+++ b/
src/src/malware.c
@@
-1453,7
+1453,6
@@
badseek: err = errno;
uschar av_buffer[1024];
uschar *hostname = US"";
host_item connhost;
uschar av_buffer[1024];
uschar *hostname = US"";
host_item connhost;
- uschar *clamav_fbuf;
int clam_fd, result;
unsigned int fsize_uint;
BOOL use_scan_command = FALSE;
int clam_fd, result;
unsigned int fsize_uint;
BOOL use_scan_command = FALSE;
@@
-1631,6
+1630,9
@@
badseek: err = errno;
if (!use_scan_command)
{
struct stat st;
if (!use_scan_command)
{
struct stat st;
+#ifdef EXIM_TCP_CORK
+ BOOL corked = TRUE;
+#endif
/* New protocol: "zINSTREAM\n" followed by a sequence of <length><data>
chunks, <n> a 4-byte number (network order), terminated by a zero-length
chunk. */
/* New protocol: "zINSTREAM\n" followed by a sequence of <length><data>
chunks, <n> a 4-byte number (network order), terminated by a zero-length
chunk. */
@@
-1675,7
+1677,8
@@
badseek: err = errno;
/* send file size */
#ifdef EXIM_TCP_CORK
/* send file size */
#ifdef EXIM_TCP_CORK
- (void) setsockopt(clam_fd, IPPROTO_TCP, EXIM_TCP_CORK, US &on, sizeof(on));
+ (void) setsockopt(malware_daemon_ctx.sock, IPPROTO_TCP, EXIM_TCP_CORK,
+ US &on, sizeof(on));
#endif
send_size = htonl(fsize_uint);
if (send(malware_daemon_ctx.sock, &send_size, sizeof(send_size), 0) < 0)
#endif
send_size = htonl(fsize_uint);
if (send(malware_daemon_ctx.sock, &send_size, sizeof(send_size), 0) < 0)
@@
-1684,6
+1687,7
@@
badseek: err = errno;
malware_daemon_ctx.sock);
/* send file body */
malware_daemon_ctx.sock);
/* send file body */
+ /*XXX sendfile? */
while (fsize_uint)
{
unsigned n = MIN(fsize_uint, big_buffer_size);
while (fsize_uint)
{
unsigned n = MIN(fsize_uint, big_buffer_size);
@@
-1692,11
+1696,19
@@
badseek: err = errno;
string_sprintf("can't read spool file %s: %s",
eml_filename, strerror(errno)),
malware_daemon_ctx.sock);
string_sprintf("can't read spool file %s: %s",
eml_filename, strerror(errno)),
malware_daemon_ctx.sock);
- if (
(n = send(malware_daemon_ctx.sock, clamav_fbuf, n, 0)
) < 0)
+ if (
send(malware_daemon_ctx.sock, big_buffer, (size_t)n, 0
) < 0)
return m_panic_defer_3(scanent, NULL,
return m_panic_defer_3(scanent, NULL,
- string_sprintf("unable to send file body to socket (%s)
", hostname
),
+ string_sprintf("unable to send file body to socket (%s)
: %s", hostname, strerror(errno)
),
malware_daemon_ctx.sock);
fsize_uint -= n;
malware_daemon_ctx.sock);
fsize_uint -= n;
+#ifdef EXIM_TCP_CORK
+ if (corked)
+ {
+ corked = FALSE;
+ (void) setsockopt(malware_daemon_ctx.sock, IPPROTO_TCP, EXIM_TCP_CORK,
+ US &off, sizeof(off));
+ }
+#endif
}
send_final_zeroblock = 0;
}
send_final_zeroblock = 0;
@@
-1704,9
+1716,6
@@
badseek: err = errno;
return m_panic_defer_3(scanent, NULL,
string_sprintf("unable to send file terminator to socket (%s)", hostname),
malware_daemon_ctx.sock);
return m_panic_defer_3(scanent, NULL,
string_sprintf("unable to send file terminator to socket (%s)", hostname),
malware_daemon_ctx.sock);
-#ifdef EXIM_TCP_CORK
- (void) setsockopt(clam_fd, IPPROTO_TCP, EXIM_TCP_CORK, US &off, sizeof(off));
-#endif
}
else
{ /* use scan command */
}
else
{ /* use scan command */