A general spring-cleaning (in autumn) to fix up signed/unsigned warnings.
[openssl.git] / ssl / ssltest.c
index 49360d5f9f064bb1a70c2294adc72dd94a4af41b..5aadfa51d0748111ddebc9b24ff3b44fe39a5780 100644 (file)
 
 #ifdef OPENSSL_SYS_WINDOWS
 #include <winsock.h>
-#include "../crypto/bio/bss_file.c"
 #else
 #include OPENSSL_UNISTD
 #endif
 
 /* There is really no standard for this, so let's assign some tentative
    numbers.  In any case, these numbers are only for this test */
-#define COMP_RLE       1
-#define COMP_ZLIB      2
+#define COMP_RLE       255
+#define COMP_ZLIB      1
 
 static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
 #ifndef OPENSSL_NO_RSA
@@ -304,7 +303,7 @@ static void lock_dbg_cb(int mode, int type, const char *file, int line)
                goto err;
                }
 
-       if (type < 0 || type > CRYPTO_NUM_LOCKS)
+       if (type < 0 || type >= CRYPTO_NUM_LOCKS)
                {
                errstr = "type out of bounds";
                goto err;
@@ -374,7 +373,7 @@ int main(int argc, char *argv[])
        SSL_METHOD *meth=NULL;
        SSL *c_ssl,*s_ssl;
        int number=1,reuse=0;
-       long bytes=1L;
+       long bytes=256L;
 #ifndef OPENSSL_NO_DH
        DH *dh;
        int dhe1024 = 0, dhe1024dsa = 0;
@@ -388,6 +387,7 @@ int main(int argc, char *argv[])
        clock_t s_time = 0, c_time = 0;
        int comp = 0;
        COMP_METHOD *cm = NULL;
+       STACK_OF(SSL_COMP) *ssl_comp_methods = NULL;
 
        verbose = 0;
        debug = 0;
@@ -595,7 +595,14 @@ bad:
        if (cm != NULL)
                {
                if (cm->type != NID_undef)
-                       SSL_COMP_add_compression_method(comp, cm);
+                       {
+                       if (SSL_COMP_add_compression_method(comp, cm) != 0)
+                               {
+                               fprintf(stderr,
+                                       "Failed to add compression method\n");
+                               ERR_print_errors_fp(stderr);
+                               }
+                       }
                else
                        {
                        fprintf(stderr,
@@ -606,6 +613,19 @@ bad:
                        ERR_print_errors_fp(stderr);
                        }
                }
+       ssl_comp_methods = SSL_COMP_get_compression_methods();
+       fprintf(stderr, "Available compression methods:\n");
+       {
+       int j, n = sk_SSL_COMP_num(ssl_comp_methods);
+       if (n == 0)
+               fprintf(stderr, "  NONE\n");
+       else
+               for (j = 0; j < n; j++)
+                       {
+                       SSL_COMP *c = sk_SSL_COMP_value(ssl_comp_methods, j);
+                       fprintf(stderr, "  %d: %s\n", c->id, c->name);
+                       }
+       }
 
 #if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
        if (ssl2)
@@ -1330,8 +1350,8 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
                        {
                        if (c_write)
                                {
-                               j=(cw_num > (long)sizeof(cbuf))
-                                       ?sizeof(cbuf):(int)cw_num;
+                               j = (cw_num > (long)sizeof(cbuf)) ?
+                                       (int)sizeof(cbuf) : (int)cw_num;
                                i=BIO_write(c_bio,cbuf,j);
                                if (i < 0)
                                        {
@@ -1461,8 +1481,8 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
                                }
                        else
                                {
-                               j=(sw_num > (long)sizeof(sbuf))?
-                                       sizeof(sbuf):(int)sw_num;
+                               j = (sw_num > (long)sizeof(sbuf)) ?
+                                       (int)sizeof(sbuf) : (int)sw_num;
                                i=BIO_write(s_bio,sbuf,j);
                                if (i < 0)
                                        {
@@ -1598,7 +1618,7 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
                (void)BIO_flush(bio_err);
                if(!RSA_generate_key_ex(rsa_tmp,keylength,RSA_F4,NULL))
                        {
-                       BIO_printf(bio_err, "Error generating key.", keylength);
+                       BIO_printf(bio_err, "Error generating key.");
                        RSA_free(rsa_tmp);
                        rsa_tmp = NULL;
                        }