]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
demos/sslecho/echecho.c: check return values of SSL_* calls
authorEugene Syromiatnikov <esyr@openssl.org>
Sat, 27 Jun 2026 10:44:06 +0000 (12:44 +0200)
committerNorbert Pocs <norbertp@openssl.org>
Mon, 20 Jul 2026 11:18:33 +0000 (13:18 +0200)
As otherwise it triggers -Werror=unused-result when built
with --strict-warnings.

Complements: 50580382caca "Documents initial agreed APIs for Encrypted Client Hello (ECH) and includes a minimal demo for some of those APIs."
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Mon Jul 20 11:19:01 2026
(Merged from https://github.com/openssl/openssl/pull/31751)

demos/sslecho/echecho.c

index c8dc57b2631ae39a9eaacda4ee53a7318bf7064e..71b3d5565b38bc794607a2d812e6f82eb8140d70 100644 (file)
@@ -251,7 +251,11 @@ int main(int argc, char **argv)
 
             /* Create server SSL structure using newly accepted client socket */
             ssl = SSL_new(ssl_ctx);
-            SSL_set_fd(ssl, client_skt);
+            if (SSL_set_fd(ssl, client_skt) <= 0) {
+                puts("Unable to set fd for the SSL object");
+                ERR_print_errors_fp(stderr);
+                exit(EXIT_FAILURE);
+            }
 
             /* Wait for SSL connection from the client */
             if (SSL_accept(ssl) <= 0) {
@@ -332,11 +336,19 @@ int main(int argc, char **argv)
 
         /* Create client SSL structure using dedicated client socket */
         ssl = SSL_new(ssl_ctx);
-        SSL_set_fd(ssl, client_skt);
+        if (SSL_set_fd(ssl, client_skt) <= 0) {
+            puts("Unable to set fd for the SSL object");
+            ERR_print_errors_fp(stderr);
+            exit(EXIT_FAILURE);
+        }
         /* Set hostname for SNI */
         SSL_set_tlsext_host_name(ssl, rem_server_ip);
         /* Configure server hostname check */
-        SSL_set1_ipaddr(ssl, rem_server_ip);
+        if (SSL_set1_ipaddr(ssl, rem_server_ip) <= 0) {
+            puts("Unable to set IP address for the SSL object");
+            ERR_print_errors_fp(stderr);
+            exit(EXIT_FAILURE);
+        }
 
         /* Now do SSL connect with server */
         if (SSL_connect(ssl) == 1) {