return FALSE;
}
-if (is_tainted2(expint, LOG_MAIN|LOG_PANIC, "Tainted value '%s' from '%s' for interface", expint, istring))
+if (is_tainted(expint))
{
+ log_write(0, LOG_MAIN|LOG_PANIC,
+ "attempt to use tainted value '%s' from '%s' for interface",
+ expint, istring);
addr->transport_return = PANIC;
addr->message = string_sprintf("failed to expand \"interface\" "
"option for %s: configuration error", msg);
#ifdef TCP_FASTOPEN
+/* Try to record if TFO was attmepted and if it was successfully used. */
+
static void
tfo_out_check(int sock)
{
+static BOOL done_once = FALSE;
+
+if (done_once) return;
+done_once = TRUE;
+
# ifdef __FreeBSD__
struct tcp_info tinfo;
socklen_t len = sizeof(tinfo);
#ifndef DISABLE_EVENT
deliver_host_address = host->address;
deliver_host_port = port;
-if (event_raise(tb->event_action, US"tcp:connect", NULL)) return -1;
+if (event_raise(tb->event_action, US"tcp:connect", NULL, &errno)) return -1;
#endif
if ((sock = ip_socket(SOCK_STREAM, host_af)) < 0) return -1;
{
int sock = socks_sock_connect(sc->host, sc->host_af, port, sc->interface,
sc->tblock, ob->connect_timeout);
-
+
if (sock >= 0)
{
if (early_data && early_data->data && early_data->len)
int rc;
int n = outblock->ptr - outblock->buffer;
BOOL more = mode == SCMD_MORE;
+client_conn_ctx * cctx;
HDEBUG(D_transport|D_acl) debug_printf_indent("cmd buf flush %d bytes%s\n", n,
more ? " (more expected)" : "");
+if (!(cctx = outblock->cctx))
+ {
+ log_write(0, LOG_MAIN|LOG_PANIC, "null conn-context pointer");
+ errno = 0;
+ return FALSE;
+ }
+
#ifndef DISABLE_TLS
-if (outblock->cctx->tls_ctx)
- rc = tls_write(outblock->cctx->tls_ctx, outblock->buffer, n, more);
+if (cctx->tls_ctx) /*XXX have seen a null cctx here, rvfy sending QUIT, hence check above */
+ rc = tls_write(cctx->tls_ctx, outblock->buffer, n, more);
else
#endif
requirement: TFO with data can, in rare cases, replay the data to the
receiver. */
- if ( (outblock->cctx->sock = smtp_connect(outblock->conn_args, &early_data))
+ if ( (cctx->sock = smtp_connect(outblock->conn_args, &early_data))
< 0)
return FALSE;
outblock->conn_args = NULL;
}
else
{
- rc = send(outblock->cctx->sock, outblock->buffer, n,
+ rc = send(cctx->sock, outblock->buffer, n,
#ifdef MSG_MORE
more ? MSG_MORE : 0
#else
https://bugzilla.redhat.com/show_bug.cgi?id=1803806 */
if (!more)
- setsockopt(outblock->cctx->sock, IPPROTO_TCP, TCP_CORK, &off, sizeof(off));
+ setsockopt(cctx->sock, IPPROTO_TCP, TCP_CORK, &off, sizeof(off));
#endif
}
}
+/* This might be called both due to callout and then from delivery.
+Use memory that will not be released between those phases.
+*/
+static void
+smtp_debug_resp(const uschar * buf)
+{
+#ifndef DISABLE_CLIENT_CMD_LOG
+int old_pool = store_pool;
+store_pool = POOL_PERM;
+client_cmd_log = string_append_listele_n(client_cmd_log, ':', buf,
+ buf[3] == ' ' ? 3 : 4);
+store_pool = old_pool;
+#endif
+}
+
+
/*************************************************
* Write SMTP command *
*************************************************/
*/
int
-smtp_write_command(void * sx, int mode, const char *format, ...)
+smtp_write_command(void * sx, int mode, const char * format, ...)
{
smtp_outblock * outblock = &((smtp_context *)sx)->outblock;
int rc = 0;
while (*p) *p++ = '*';
}
- HDEBUG(D_transport|D_acl|D_v) debug_printf_indent(" SMTP%c> %s\n",
- mode == SCMD_BUFFER ? '|' : mode == SCMD_MORE ? '+' : '>',
- big_buffer);
+ smtp_debug_cmd(big_buffer, mode);
}
if (mode != SCMD_BUFFER)
uschar * ptr = buffer;
int count = 0;
time_t timelimit = time(NULL) + timeout;
+BOOL yield = FALSE;
errno = 0; /* Ensure errno starts out zero */
+buffer[0] = '\0';
#ifndef DISABLE_PIPE_CONNECT
if (sx->pending_BANNER || sx->pending_EHLO)
if ((rc = smtp_reap_early_pipe(sx, &count)) != OK)
{
DEBUG(D_transport) debug_printf("failed reaping pipelined cmd responsess\n");
- buffer[0] = '\0';
if (rc == DEFER) errno = ERRNO_TLSFAILURE;
- return FALSE;
+ goto out;
}
}
#endif
(ptr[3] != '-' && ptr[3] != ' ' && ptr[3] != 0))
{
errno = ERRNO_SMTPFORMAT; /* format error */
- return FALSE;
+ goto out;
}
/* If the line we have just read is a terminal line, line, we are done.
}
#ifdef TCP_FASTOPEN
- tfo_out_check(sx->cctx.sock);
+tfo_out_check(sx->cctx.sock);
#endif
/* Return a value that depends on the SMTP return code. On some systems a
timeouts, lost connections, etc. */
errno = 0;
-return buffer[0] == okdigit;
+yield = buffer[0] == okdigit;
+
+out:
+ smtp_debug_resp(buffer);
+ return yield;
}
/* End of smtp_out.c */