diff options
Diffstat (limited to 'src/lib/libssl/src/ssl/ssltest.c')
-rw-r--r-- | src/lib/libssl/src/ssl/ssltest.c | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/src/lib/libssl/src/ssl/ssltest.c b/src/lib/libssl/src/ssl/ssltest.c index 342c59e659..5fccc48b71 100644 --- a/src/lib/libssl/src/ssl/ssltest.c +++ b/src/lib/libssl/src/ssl/ssltest.c | |||
@@ -109,11 +109,8 @@ | |||
109 | * | 109 | * |
110 | */ | 110 | */ |
111 | 111 | ||
112 | #define _XOPEN_SOURCE 600 /* Or gethostname won't be declared properly | 112 | #define _BSD_SOURCE 1 /* Or gethostname won't be declared properly |
113 | on Linux and GNU platforms. */ | 113 | on Linux and GNU platforms. */ |
114 | #define _XOPEN_SOURCE_EXTENDED 1 /* Or gethostname won't be declared properly | ||
115 | on Compaq platforms (at least with DEC C). | ||
116 | */ | ||
117 | 114 | ||
118 | #include <assert.h> | 115 | #include <assert.h> |
119 | #include <errno.h> | 116 | #include <errno.h> |
@@ -124,6 +121,7 @@ | |||
124 | #include <time.h> | 121 | #include <time.h> |
125 | #include <inttypes.h> | 122 | #include <inttypes.h> |
126 | 123 | ||
124 | #define USE_SOCKETS | ||
127 | #include "e_os.h" | 125 | #include "e_os.h" |
128 | 126 | ||
129 | #include <openssl/bio.h> | 127 | #include <openssl/bio.h> |
@@ -131,12 +129,20 @@ | |||
131 | #include <openssl/evp.h> | 129 | #include <openssl/evp.h> |
132 | #include <openssl/x509.h> | 130 | #include <openssl/x509.h> |
133 | #include <openssl/ssl.h> | 131 | #include <openssl/ssl.h> |
132 | #ifndef OPENSSL_NO_ENGINE | ||
134 | #include <openssl/engine.h> | 133 | #include <openssl/engine.h> |
134 | #endif | ||
135 | #include <openssl/err.h> | 135 | #include <openssl/err.h> |
136 | #include <openssl/rand.h> | 136 | #include <openssl/rand.h> |
137 | |||
138 | #define _XOPEN_SOURCE_EXTENDED 1 /* Or gethostname won't be declared properly | ||
139 | on Compaq platforms (at least with DEC C). | ||
140 | Do not try to put it earlier, or IPv6 includes | ||
141 | get screwed... | ||
142 | */ | ||
143 | |||
137 | #ifdef OPENSSL_SYS_WINDOWS | 144 | #ifdef OPENSSL_SYS_WINDOWS |
138 | #include <winsock.h> | 145 | #include <winsock.h> |
139 | #include "../crypto/bio/bss_file.c" | ||
140 | #else | 146 | #else |
141 | #include OPENSSL_UNISTD | 147 | #include OPENSSL_UNISTD |
142 | #endif | 148 | #endif |
@@ -144,6 +150,9 @@ | |||
144 | #ifdef OPENSSL_SYS_VMS | 150 | #ifdef OPENSSL_SYS_VMS |
145 | # define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM" | 151 | # define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM" |
146 | # define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM" | 152 | # define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM" |
153 | #elif defined(OPENSSL_SYS_WINCE) | ||
154 | # define TEST_SERVER_CERT "\\OpenSSL\\server.pem" | ||
155 | # define TEST_CLIENT_CERT "\\OpenSSL\\client.pem" | ||
147 | #else | 156 | #else |
148 | # define TEST_SERVER_CERT "../apps/server.pem" | 157 | # define TEST_SERVER_CERT "../apps/server.pem" |
149 | # define TEST_CLIENT_CERT "../apps/client.pem" | 158 | # define TEST_CLIENT_CERT "../apps/client.pem" |
@@ -365,7 +374,9 @@ int main(int argc, char *argv[]) | |||
365 | verbose = 0; | 374 | verbose = 0; |
366 | debug = 0; | 375 | debug = 0; |
367 | cipher = 0; | 376 | cipher = 0; |
368 | 377 | ||
378 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | ||
379 | |||
369 | CRYPTO_set_locking_callback(lock_dbg_cb); | 380 | CRYPTO_set_locking_callback(lock_dbg_cb); |
370 | 381 | ||
371 | /* enable memory leak checking unless explicitly disabled */ | 382 | /* enable memory leak checking unless explicitly disabled */ |
@@ -383,7 +394,6 @@ int main(int argc, char *argv[]) | |||
383 | 394 | ||
384 | RAND_seed(rnd_seed, sizeof rnd_seed); | 395 | RAND_seed(rnd_seed, sizeof rnd_seed); |
385 | 396 | ||
386 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | ||
387 | bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE); | 397 | bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE); |
388 | 398 | ||
389 | argc--; | 399 | argc--; |
@@ -406,7 +416,7 @@ int main(int argc, char *argv[]) | |||
406 | #ifndef OPENSSL_NO_DH | 416 | #ifndef OPENSSL_NO_DH |
407 | dhe1024=1; | 417 | dhe1024=1; |
408 | #else | 418 | #else |
409 | fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"; | 419 | fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"); |
410 | #endif | 420 | #endif |
411 | } | 421 | } |
412 | else if (strcmp(*argv,"-dhe1024dsa") == 0) | 422 | else if (strcmp(*argv,"-dhe1024dsa") == 0) |
@@ -414,7 +424,7 @@ int main(int argc, char *argv[]) | |||
414 | #ifndef OPENSSL_NO_DH | 424 | #ifndef OPENSSL_NO_DH |
415 | dhe1024dsa=1; | 425 | dhe1024dsa=1; |
416 | #else | 426 | #else |
417 | fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"; | 427 | fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"); |
418 | #endif | 428 | #endif |
419 | } | 429 | } |
420 | else if (strcmp(*argv,"-no_dhe") == 0) | 430 | else if (strcmp(*argv,"-no_dhe") == 0) |
@@ -531,7 +541,7 @@ bad: | |||
531 | "the test anyway (and\n-d to see what happens), " | 541 | "the test anyway (and\n-d to see what happens), " |
532 | "or add one of -ssl2, -ssl3, -tls1, -reuse\n" | 542 | "or add one of -ssl2, -ssl3, -tls1, -reuse\n" |
533 | "to avoid protocol mismatch.\n"); | 543 | "to avoid protocol mismatch.\n"); |
534 | exit(1); | 544 | EXIT(1); |
535 | } | 545 | } |
536 | 546 | ||
537 | if (print_time) | 547 | if (print_time) |
@@ -687,10 +697,16 @@ bad: | |||
687 | #ifndef OPENSSL_NO_KRB5 | 697 | #ifndef OPENSSL_NO_KRB5 |
688 | if (c_ssl && c_ssl->kssl_ctx) | 698 | if (c_ssl && c_ssl->kssl_ctx) |
689 | { | 699 | { |
690 | char localhost[257]; | 700 | char localhost[MAXHOSTNAMELEN+2]; |
691 | 701 | ||
692 | if (gethostname(localhost, 256) == 0) | 702 | if (gethostname(localhost, sizeof localhost-1) == 0) |
693 | { | 703 | { |
704 | localhost[sizeof localhost-1]='\0'; | ||
705 | if(strlen(localhost) == sizeof localhost-1) | ||
706 | { | ||
707 | BIO_printf(bio_err,"localhost name too long\n"); | ||
708 | goto end; | ||
709 | } | ||
694 | kssl_ctx_setstring(c_ssl->kssl_ctx, KSSL_SERVER, | 710 | kssl_ctx_setstring(c_ssl->kssl_ctx, KSSL_SERVER, |
695 | localhost); | 711 | localhost); |
696 | } | 712 | } |
@@ -746,7 +762,9 @@ end: | |||
746 | #ifndef OPENSSL_NO_RSA | 762 | #ifndef OPENSSL_NO_RSA |
747 | free_tmp_rsa(); | 763 | free_tmp_rsa(); |
748 | #endif | 764 | #endif |
765 | #ifndef OPENSSL_NO_ENGINE | ||
749 | ENGINE_cleanup(); | 766 | ENGINE_cleanup(); |
767 | #endif | ||
750 | CRYPTO_cleanup_all_ex_data(); | 768 | CRYPTO_cleanup_all_ex_data(); |
751 | ERR_free_strings(); | 769 | ERR_free_strings(); |
752 | ERR_remove_state(0); | 770 | ERR_remove_state(0); |
@@ -836,6 +854,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count, | |||
836 | int i, r; | 854 | int i, r; |
837 | clock_t c_clock = clock(); | 855 | clock_t c_clock = clock(); |
838 | 856 | ||
857 | memset(cbuf, 0, sizeof(cbuf)); | ||
858 | |||
839 | if (debug) | 859 | if (debug) |
840 | if (SSL_in_init(c_ssl)) | 860 | if (SSL_in_init(c_ssl)) |
841 | printf("client waiting in SSL_connect - %s\n", | 861 | printf("client waiting in SSL_connect - %s\n", |
@@ -920,6 +940,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count, | |||
920 | int i, r; | 940 | int i, r; |
921 | clock_t s_clock = clock(); | 941 | clock_t s_clock = clock(); |
922 | 942 | ||
943 | memset(sbuf, 0, sizeof(sbuf)); | ||
944 | |||
923 | if (debug) | 945 | if (debug) |
924 | if (SSL_in_init(s_ssl)) | 946 | if (SSL_in_init(s_ssl)) |
925 | printf("server waiting in SSL_accept - %s\n", | 947 | printf("server waiting in SSL_accept - %s\n", |
@@ -1163,6 +1185,9 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count) | |||
1163 | int c_write,s_write; | 1185 | int c_write,s_write; |
1164 | int do_server=0,do_client=0; | 1186 | int do_server=0,do_client=0; |
1165 | 1187 | ||
1188 | memset(cbuf,0,sizeof(cbuf)); | ||
1189 | memset(sbuf,0,sizeof(sbuf)); | ||
1190 | |||
1166 | c_to_s=BIO_new(BIO_s_mem()); | 1191 | c_to_s=BIO_new(BIO_s_mem()); |
1167 | s_to_c=BIO_new(BIO_s_mem()); | 1192 | s_to_c=BIO_new(BIO_s_mem()); |
1168 | if ((s_to_c == NULL) || (c_to_s == NULL)) | 1193 | if ((s_to_c == NULL) || (c_to_s == NULL)) |
@@ -1444,7 +1469,8 @@ static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx) | |||
1444 | { | 1469 | { |
1445 | char *s,buf[256]; | 1470 | char *s,buf[256]; |
1446 | 1471 | ||
1447 | s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),buf,256); | 1472 | s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),buf, |
1473 | sizeof buf); | ||
1448 | if (s != NULL) | 1474 | if (s != NULL) |
1449 | { | 1475 | { |
1450 | if (ok) | 1476 | if (ok) |