summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-07-12 13:16:10 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2018-02-19 15:29:33 +0100
commitacbf36bc167d81e7a4dc2afe50fdd4537ebbd07a (patch)
tree1dfbc37a5d8afaea0d6720d64f46c8ecd21159b1 /tests
parent5ad549bb4d968e8e7ff4a5c97a3935b707fa5967 (diff)
downloadgnutls-acbf36bc167d81e7a4dc2afe50fdd4537ebbd07a.tar.gz
tests: safer use of gnutls_bye in _test_cli_serv()
In addition make sure we check gnutls_priority_set() for errors. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/utils-adv.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/utils-adv.c b/tests/utils-adv.c
index 22ef18736e..1986e50bd1 100644
--- a/tests/utils-adv.c
+++ b/tests/utils-adv.c
@@ -69,7 +69,10 @@ _test_cli_serv(gnutls_certificate_credentials_t server_cred,
gnutls_init(&server, GNUTLS_SERVER);
gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
server_cred);
- gnutls_priority_set_direct(server, serv_prio, NULL);
+ ret = gnutls_priority_set_direct(server, serv_prio, NULL);
+ if (ret < 0) {
+ fail("error in server priority: %s\n", serv_prio);
+ }
gnutls_transport_set_push_function(server, server_push);
gnutls_transport_set_pull_function(server, server_pull);
gnutls_transport_set_ptr(server, server);
@@ -95,7 +98,10 @@ _test_cli_serv(gnutls_certificate_credentials_t server_cred,
if (ret < 0)
exit(1);
- gnutls_priority_set_direct(client, cli_prio, NULL);
+ ret = gnutls_priority_set_direct(client, cli_prio, NULL);
+ if (ret < 0) {
+ fail("error in client priority: %s\n", cli_prio);
+ }
gnutls_transport_set_push_function(client, client_push);
gnutls_transport_set_pull_function(client, client_pull);
gnutls_transport_set_ptr(client, client);
@@ -157,6 +163,11 @@ _test_cli_serv(gnutls_certificate_credentials_t server_cred,
}
}
+ if (cret >= 0)
+ gnutls_bye(client, GNUTLS_SHUT_RDWR);
+ if (sret >= 0)
+ gnutls_bye(server, GNUTLS_SHUT_RDWR);
+
ret = 0;
cleanup:
if (client_cb)
@@ -164,9 +175,6 @@ _test_cli_serv(gnutls_certificate_credentials_t server_cred,
if (server_cb)
server_cb(server, priv);
- gnutls_bye(client, GNUTLS_SHUT_RDWR);
- gnutls_bye(server, GNUTLS_SHUT_RDWR);
-
gnutls_deinit(client);
gnutls_deinit(server);