Avoid some shadowed variable names.
[openssl.git] / ssl / ssl_ciph.c
index d4f86f6ed90d31ba972212fc74527848cd5736b0..545999ac6eb65f653f1e59dc1f4048a2c0e678b8 100644 (file)
@@ -715,13 +715,14 @@ static int ssl_cipher_process_rulestr(const char *rule_str,
                         * So additionally check whether the cipher name found
                         * has the correct length. We can save a strlen() call:
                         * just checking for the '\0' at the right place is
-                        * sufficient, we have to strncmp() anyway.
+                        * sufficient, we have to strncmp() anyway. (We cannot
+                        * use strcmp(), because buf is not '\0' terminated.)
                         */
                         j = found = 0;
                         while (ca_list[j])
                                {
-                               if ((ca_list[j]->name[buflen] == '\0') &&
-                                   !strncmp(buf, ca_list[j]->name, buflen))
+                               if (!strncmp(buf, ca_list[j]->name, buflen) &&
+                                   (ca_list[j]->name[buflen] == '\0'))
                                        {
                                        found = 1;
                                        break;
@@ -951,7 +952,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method,
 char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
        {
        int is_export,pkl,kl;
-       char *ver,*exp;
+       char *ver,*exp_str;
        char *kx,*au,*enc,*mac;
        unsigned long alg,alg2,alg_s;
 #ifdef KSSL_DEBUG
@@ -967,7 +968,7 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
        is_export=SSL_C_IS_EXPORT(cipher);
        pkl=SSL_C_EXPORT_PKEYLENGTH(cipher);
        kl=SSL_C_EXPORT_KEYLENGTH(cipher);
-       exp=is_export?" export":"";
+       exp_str=is_export?" export":"";
        
        if (alg & SSL_SSLV2)
                ver="SSLv2";
@@ -1093,9 +1094,9 @@ char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
                return("Buffer too small");
 
 #ifdef KSSL_DEBUG
-       BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp,alg);
+       BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp_str,alg);
 #else
-       BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp);
+       BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp_str);
 #endif /* KSSL_DEBUG */
        return(buf);
        }
@@ -1181,17 +1182,33 @@ int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm)
        comp->id=id;
        comp->method=cm;
        load_builtin_compressions();
-       if ((ssl_comp_methods == NULL)
+       if (ssl_comp_methods
+               && !sk_SSL_COMP_find(ssl_comp_methods,comp))
+               {
+               OPENSSL_free(comp);
+               MemCheck_on();
+               SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,SSL_R_DUPLICATE_COMPRESSION_ID);
+               return(1);
+               }
+       else if ((ssl_comp_methods == NULL)
                || !sk_SSL_COMP_push(ssl_comp_methods,comp))
                {
                OPENSSL_free(comp);
                MemCheck_on();
                SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,ERR_R_MALLOC_FAILURE);
-               return(0);
+               return(1);
                }
        else
                {
                MemCheck_on();
-               return(1);
+               return(0);
                }
        }
+
+const char *SSL_COMP_get_name(const COMP_METHOD *comp)
+       {
+       if (comp)
+               return comp->name;
+       return NULL;
+       }
+