Commit eb7d128d17 for openssl.org

commit eb7d128d17dfa2dc7954b086348accec946bd21c
Author: Prudhvi raj <prudhvirajkonda8@gmail.com>
Date:   Sun Nov 15 19:10:45 2026 +0530

    demos: fix sslecho receive buffer boundary handling

    The rxbuf array in the sslecho, echecho, and dtlsecho demos was declared
    as char rxbuf[128] with rxcap set to sizeof(rxbuf) (128).  SSL_read()
    could return up to 128 bytes, and the subsequent null termination
    rxbuf[rxlen] = 0 would then write one byte past the end of the buffer
    at index 128.

    This affected both the server-side and client-side receive paths in all
    three demo programs.

    Fix by declaring rxbuf with one extra byte (128 + 1 = 129) and setting
    rxcap to sizeof(rxbuf) - 1 (128). This preserves the maximum 128-byte
    read capacity while ensuring that the null terminator at rxbuf[128]
    stays within bounds.

    Resolves: https://github.com/openssl/openssl/issues/33730
    Fixes: ef6e427b4026 "DTLS 1.3 Demo and Bug Fix"
    Fixes: 50580382caca "Documents initial agreed APIs for Encrypted Client Hello (ECH) and includes a minimal demo for some of those APIs."
    Fixes: 801c638c5040 "Added Simple SSL Echo Client/Server to demos."
    Reviewed-by: Matt Caswell <matt@openssl.foundation>
    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    Merge-date: Fri Nov 20 17:51:06 2026
    Merged-from: https://github.com/openssl/openssl/pull/33747

diff --git a/demos/dtlsecho/main.c b/demos/dtlsecho/main.c
index 88d7da32b7..87da1581f7 100644
--- a/demos/dtlsecho/main.c
+++ b/demos/dtlsecho/main.c
@@ -221,8 +221,8 @@ int main(int argc, char **argv)
     char buffer[BUFFERSIZE];
     char *txbuf;

-    char rxbuf[128];
-    size_t rxcap = sizeof(rxbuf);
+    char rxbuf[128 + 1];
+    size_t rxcap = sizeof(rxbuf) - 1;
     int rxlen;

     char *rem_server_name = NULL;
diff --git a/demos/sslecho/echecho.c b/demos/sslecho/echecho.c
index d9c757cba2..0847f33210 100644
--- a/demos/sslecho/echecho.c
+++ b/demos/sslecho/echecho.c
@@ -199,8 +199,8 @@ int main(int argc, char **argv)
     char *txbuf = NULL;
     size_t txcap = 0;

-    char rxbuf[128];
-    size_t rxcap = sizeof(rxbuf);
+    char rxbuf[128 + 1];
+    size_t rxcap = sizeof(rxbuf) - 1;
     int rxlen;

     char *rem_server_ip = NULL;
diff --git a/demos/sslecho/main.c b/demos/sslecho/main.c
index 7b2738332d..de16af161b 100644
--- a/demos/sslecho/main.c
+++ b/demos/sslecho/main.c
@@ -154,8 +154,8 @@ int main(int argc, char **argv)
     char buffer[BUFFERSIZE];
     char *txbuf;

-    char rxbuf[128];
-    size_t rxcap = sizeof(rxbuf);
+    char rxbuf[128 + 1];
+    size_t rxcap = sizeof(rxbuf) - 1;
     int rxlen;

     char *rem_server_name = NULL;