From: Matt Caswell Date: Wed, 8 Apr 2026 15:36:42 +0000 (+0100) Subject: Fix off-by-one s_client overflows X-Git-Tag: openssl-4.0.0~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9603120b5fac0d7d3b5c0fdca7ca211636b3f9df;p=thirdparty%2Fopenssl.git Fix off-by-one s_client overflows There are one byte buffer overflows possible in s_client's handling of STARTTLS in various protocols. If a server's response fills the entire buffer (16k) then we attempt to add a NUL terminator one byte off the end of the buffer. This was reported by Igor Morgenstern from AISLE to openssl-security and assessed by the security team as "bug or hardening only". Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz Reviewed-by: Eugene Syromiatnikov Reviewed-by: Nikola Pajkovsky MergeDate: Sat Apr 11 16:25:52 2026 (Merged from https://github.com/openssl/openssl/pull/30731) --- diff --git a/apps/s_client.c b/apps/s_client.c index fa7d1a30407..ed5e322996f 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -2712,7 +2712,7 @@ re_start: "xmlns='jabber:%s' to='%s' version='1.0'>", starttls_proto == PROTO_XMPP ? "client" : "server", protohost ? protohost : host); - seen = BIO_read(sbio, mbuf, BUFSIZZ); + seen = BIO_read(sbio, mbuf, BUFSIZZ - 1); if (seen < 0) { BIO_printf(bio_err, "BIO_read failed\n"); goto end; @@ -2721,7 +2721,7 @@ re_start: while (!strstr(mbuf, ""); - seen = BIO_read(sbio, sbuf, BUFSIZZ); + seen = BIO_read(sbio, sbuf, BUFSIZZ - 1); if (seen < 0) { BIO_puts(bio_err, "BIO_read failed\n"); goto shut; @@ -2955,7 +2955,7 @@ re_start: "Didn't find STARTTLS in server response," " trying anyway...\n"); BIO_puts(sbio, "STARTTLS\r\n"); - mbuf_len = BIO_read(sbio, mbuf, BUFSIZZ); + mbuf_len = BIO_read(sbio, mbuf, BUFSIZZ - 1); if (mbuf_len < 0) { BIO_puts(bio_err, "BIO_read failed\n"); goto end; @@ -2996,7 +2996,7 @@ re_start: "Didn't find STARTTLS in server response," " trying anyway...\n"); BIO_puts(sbio, "STARTTLS\r\n"); - mbuf_len = BIO_read(sbio, mbuf, BUFSIZZ); + mbuf_len = BIO_read(sbio, mbuf, BUFSIZZ - 1); if (mbuf_len < 0) { BIO_puts(bio_err, "BIO_read failed\n"); goto end;