diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-12-09 09:54:14 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-12-09 09:54:16 +0100 |
commit | 90188bd6a9d80a9e4e3ca171198d764b274adf21 (patch) | |
tree | 74ba9326e83902ed2bf8e824ddd028cbdba9127e /tests | |
parent | c9f4970a9c497fe1690a0432ae19e9db901d2899 (diff) | |
download | gnutls-90188bd6a9d80a9e4e3ca171198d764b274adf21.tar.gz |
tests: enhanced long-session-id testtmp-long-session-id-update
This ensures that no leaks exist during exit (to avoid asan failures),
and that we test for the specific error code that gnutls_handshake()
is expected to return.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/long-session-id.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/tests/long-session-id.c b/tests/long-session-id.c index 1e38f38acf..55f0641a45 100644 --- a/tests/long-session-id.c +++ b/tests/long-session-id.c @@ -106,7 +106,6 @@ static void client(int fd, const char *prio) { int ret; unsigned r; - gnutls_anon_client_credentials_t anoncred; gnutls_certificate_credentials_t x509_cred; gnutls_session_t session; /* Need to enable anonymous KX specifically. */ @@ -118,7 +117,6 @@ static void client(int fd, const char *prio) gnutls_global_set_log_level(7); } - gnutls_anon_allocate_client_credentials(&anoncred); gnutls_certificate_allocate_credentials(&x509_cred); /* Initialize TLS session @@ -128,9 +126,6 @@ static void client(int fd, const char *prio) /* Use default priorities */ gnutls_priority_set_direct(session, prio, NULL); - /* put the anonymous credentials to the current session - */ - gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred); gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred); gnutls_transport_set_int(session, fd); @@ -148,20 +143,19 @@ static void client(int fd, const char *prio) kill(getpid(), SIGSEGV); } - if (ret < 0) { - fprintf(stderr, "client: Handshake failed (expected)\n"); - gnutls_perror(ret); - exit(0); + if (ret == GNUTLS_E_ILLEGAL_PARAMETER) { + fprintf(stderr, "client: Handshake failed (expected): %s\n", gnutls_strerror(ret)); + goto cleanup; } else { - if (debug) - fprintf(stderr, "client: Handshake was completed\n"); + fprintf(stderr, "client: Handshake was completed or failed with unknown error code(%d): %s\n", ret, gnutls_strerror(ret)); + kill(getpid(), SIGSEGV); } + cleanup: close(fd); gnutls_deinit(session); - gnutls_anon_free_client_credentials(anoncred); gnutls_certificate_free_credentials(x509_cred); gnutls_global_deinit(); @@ -175,9 +169,9 @@ static void server(int fd, const char *prio) { int ret; uint8_t id[255]; - uint8_t buffer[] = "\x16\x03\x00\x01\x25" + uint8_t buffer[] = "\x16\x03\x01\x01\x25" "\x02\x00\x01\x21" - "\x03\x00"/*Server Version */ + "\x03\x01"/*Server Version */ /*Random*/"\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00\x00" /*SessionID*/"\xfe"; |