From: Eugene Syromiatnikov Date: Sat, 27 Jun 2026 10:44:06 +0000 (+0200) Subject: demos/sslecho/echecho.c: check return values of SSL_* calls X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=87b0f363dccbdbdbeb22202de0c1db3e5fbc4f72;p=thirdparty%2Fopenssl.git demos/sslecho/echecho.c: check return values of SSL_* calls 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 Reviewed-by: Neil Horman Reviewed-by: Bob Beck MergeDate: Mon Jul 20 11:19:01 2026 (Merged from https://github.com/openssl/openssl/pull/31751) --- diff --git a/demos/sslecho/echecho.c b/demos/sslecho/echecho.c index c8dc57b2631..71b3d5565b3 100644 --- a/demos/sslecho/echecho.c +++ b/demos/sslecho/echecho.c @@ -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) {