check the return value of BIO_new_file()
authorxkernel <xkernel.wang@foxmail.com>
Mon, 7 Mar 2022 07:43:16 +0000 (15:43 +0800)
committerMatt Caswell <matt@openssl.org>
Thu, 10 Mar 2022 13:57:21 +0000 (13:57 +0000)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17820)

apps/s_client.c
apps/s_server.c

index 23d429622adfe0ab18a3f8e1e5e02c57282c7167..105a243b8e6412c711ccb0a88433f0ea95f451d9 100644 (file)
@@ -1146,6 +1146,10 @@ int s_client_main(int argc, char **argv)
             break;
         case OPT_MSGFILE:
             bio_c_msg = BIO_new_file(opt_arg(), "w");
+            if (bio_c_msg == NULL) {
+                BIO_printf(bio_err, "Error writing file %s\n", opt_arg());
+                goto end;
+            }
             break;
         case OPT_TRACE:
 #ifndef OPENSSL_NO_SSL_TRACE
index 83feddca3e93b4fc3d3be74237a7e8aa4f748a23..2036d51795b50d8de0fa6a89a8c2f60229849dba 100644 (file)
@@ -1394,6 +1394,10 @@ int s_server_main(int argc, char *argv[])
             break;
         case OPT_MSGFILE:
             bio_s_msg = BIO_new_file(opt_arg(), "w");
+            if (bio_s_msg == NULL) {
+                BIO_printf(bio_err, "Error writing file %s\n", opt_arg());
+                goto end;
+            }
             break;
         case OPT_TRACE:
 #ifndef OPENSSL_NO_SSL_TRACE