From b249717db8ced250a586385f06e61cf7107d5222 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Fri, 18 Feb 2022 15:45:37 +0000 Subject: [PATCH 1/1] Specific check for null pointer --- src/src/smtp_out.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/src/smtp_out.c b/src/src/smtp_out.c index 608a781eb..fc1e6cecd 100644 --- a/src/src/smtp_out.c +++ b/src/src/smtp_out.c @@ -524,13 +524,21 @@ flush_buffer(smtp_outblock * outblock, int mode) 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 @@ -544,7 +552,7 @@ else 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; @@ -552,7 +560,7 @@ else } else { - rc = send(outblock->cctx->sock, outblock->buffer, n, + rc = send(cctx->sock, outblock->buffer, n, #ifdef MSG_MORE more ? MSG_MORE : 0 #else @@ -567,7 +575,7 @@ 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 } } -- 2.30.2