diff options
Diffstat (limited to 'src/lib/libssl/ssl_ciph.c')
-rw-r--r-- | src/lib/libssl/ssl_ciph.c | 70 |
1 files changed, 44 insertions, 26 deletions
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c index 3df5e2fa80..a7ccefa30c 100644 --- a/src/lib/libssl/ssl_ciph.c +++ b/src/lib/libssl/ssl_ciph.c | |||
@@ -74,7 +74,7 @@ | |||
74 | #define SSL_ENC_NUM_IDX 9 | 74 | #define SSL_ENC_NUM_IDX 9 |
75 | 75 | ||
76 | static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={ | 76 | static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={ |
77 | NULL,NULL,NULL,NULL,NULL,NULL, | 77 | NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL |
78 | }; | 78 | }; |
79 | 79 | ||
80 | static STACK_OF(SSL_COMP) *ssl_comp_methods=NULL; | 80 | static STACK_OF(SSL_COMP) *ssl_comp_methods=NULL; |
@@ -253,7 +253,7 @@ int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, | |||
253 | break; | 253 | break; |
254 | } | 254 | } |
255 | 255 | ||
256 | if ((i < 0) || (i > SSL_ENC_NUM_IDX)) | 256 | if ((i < 0) || (i >= SSL_ENC_NUM_IDX)) |
257 | *enc=NULL; | 257 | *enc=NULL; |
258 | else | 258 | else |
259 | { | 259 | { |
@@ -275,7 +275,7 @@ int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, | |||
275 | i= -1; | 275 | i= -1; |
276 | break; | 276 | break; |
277 | } | 277 | } |
278 | if ((i < 0) || (i > SSL_MD_NUM_IDX)) | 278 | if ((i < 0) || (i >= SSL_MD_NUM_IDX)) |
279 | *md=NULL; | 279 | *md=NULL; |
280 | else | 280 | else |
281 | *md=ssl_digest_methods[i]; | 281 | *md=ssl_digest_methods[i]; |
@@ -700,18 +700,9 @@ static int ssl_cipher_process_rulestr(const char *rule_str, | |||
700 | if (!found) | 700 | if (!found) |
701 | break; /* ignore this entry */ | 701 | break; /* ignore this entry */ |
702 | 702 | ||
703 | /* New algorithms: | 703 | algorithms |= ca_list[j]->algorithms; |
704 | * 1 - any old restrictions apply outside new mask | ||
705 | * 2 - any new restrictions apply outside old mask | ||
706 | * 3 - enforce old & new where masks intersect | ||
707 | */ | ||
708 | algorithms = (algorithms & ~ca_list[j]->mask) | /* 1 */ | ||
709 | (ca_list[j]->algorithms & ~mask) | /* 2 */ | ||
710 | (algorithms & ca_list[j]->algorithms); /* 3 */ | ||
711 | mask |= ca_list[j]->mask; | 704 | mask |= ca_list[j]->mask; |
712 | algo_strength = (algo_strength & ~ca_list[j]->mask_strength) | | 705 | algo_strength |= ca_list[j]->algo_strength; |
713 | (ca_list[j]->algo_strength & ~mask_strength) | | ||
714 | (algo_strength & ca_list[j]->algo_strength); | ||
715 | mask_strength |= ca_list[j]->mask_strength; | 706 | mask_strength |= ca_list[j]->mask_strength; |
716 | 707 | ||
717 | if (!multi) break; | 708 | if (!multi) break; |
@@ -765,7 +756,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, | |||
765 | { | 756 | { |
766 | int ok, num_of_ciphers, num_of_alias_max, num_of_group_aliases; | 757 | int ok, num_of_ciphers, num_of_alias_max, num_of_group_aliases; |
767 | unsigned long disabled_mask; | 758 | unsigned long disabled_mask; |
768 | STACK_OF(SSL_CIPHER) *cipherstack, *tmp_cipher_list; | 759 | STACK_OF(SSL_CIPHER) *cipherstack; |
769 | const char *rule_p; | 760 | const char *rule_p; |
770 | CIPHER_ORDER *co_list = NULL, *head = NULL, *tail = NULL, *curr; | 761 | CIPHER_ORDER *co_list = NULL, *head = NULL, *tail = NULL, *curr; |
771 | SSL_CIPHER **ca_list = NULL; | 762 | SSL_CIPHER **ca_list = NULL; |
@@ -773,8 +764,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, | |||
773 | /* | 764 | /* |
774 | * Return with error if nothing to do. | 765 | * Return with error if nothing to do. |
775 | */ | 766 | */ |
776 | if (rule_str == NULL || cipher_list == NULL || cipher_list_by_id == NULL) | 767 | if (rule_str == NULL) return(NULL); |
777 | return NULL; | ||
778 | 768 | ||
779 | if (init_ciphers) | 769 | if (init_ciphers) |
780 | { | 770 | { |
@@ -885,18 +875,46 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, | |||
885 | } | 875 | } |
886 | OPENSSL_free(co_list); /* Not needed any longer */ | 876 | OPENSSL_free(co_list); /* Not needed any longer */ |
887 | 877 | ||
888 | tmp_cipher_list = sk_SSL_CIPHER_dup(cipherstack); | 878 | /* |
889 | if (tmp_cipher_list == NULL) | 879 | * The following passage is a little bit odd. If pointer variables |
880 | * were supplied to hold STACK_OF(SSL_CIPHER) return information, | ||
881 | * the old memory pointed to is free()ed. Then, however, the | ||
882 | * cipher_list entry will be assigned just a copy of the returned | ||
883 | * cipher stack. For cipher_list_by_id a copy of the cipher stack | ||
884 | * will be created. See next comment... | ||
885 | */ | ||
886 | if (cipher_list != NULL) | ||
887 | { | ||
888 | if (*cipher_list != NULL) | ||
889 | sk_SSL_CIPHER_free(*cipher_list); | ||
890 | *cipher_list = cipherstack; | ||
891 | } | ||
892 | |||
893 | if (cipher_list_by_id != NULL) | ||
894 | { | ||
895 | if (*cipher_list_by_id != NULL) | ||
896 | sk_SSL_CIPHER_free(*cipher_list_by_id); | ||
897 | *cipher_list_by_id = sk_SSL_CIPHER_dup(cipherstack); | ||
898 | } | ||
899 | |||
900 | /* | ||
901 | * Now it is getting really strange. If something failed during | ||
902 | * the previous pointer assignment or if one of the pointers was | ||
903 | * not requested, the error condition is met. That might be | ||
904 | * discussable. The strange thing is however that in this case | ||
905 | * the memory "ret" pointed to is "free()ed" and hence the pointer | ||
906 | * cipher_list becomes wild. The memory reserved for | ||
907 | * cipher_list_by_id however is not "free()ed" and stays intact. | ||
908 | */ | ||
909 | if ( (cipher_list_by_id == NULL) || | ||
910 | (*cipher_list_by_id == NULL) || | ||
911 | (cipher_list == NULL) || | ||
912 | (*cipher_list == NULL)) | ||
890 | { | 913 | { |
891 | sk_SSL_CIPHER_free(cipherstack); | 914 | sk_SSL_CIPHER_free(cipherstack); |
892 | return NULL; | 915 | return(NULL); |
893 | } | 916 | } |
894 | if (*cipher_list != NULL) | 917 | |
895 | sk_SSL_CIPHER_free(*cipher_list); | ||
896 | *cipher_list = cipherstack; | ||
897 | if (*cipher_list_by_id != NULL) | ||
898 | sk_SSL_CIPHER_free(*cipher_list_by_id); | ||
899 | *cipher_list_by_id = tmp_cipher_list; | ||
900 | sk_SSL_CIPHER_set_cmp_func(*cipher_list_by_id,ssl_cipher_ptr_id_cmp); | 918 | sk_SSL_CIPHER_set_cmp_func(*cipher_list_by_id,ssl_cipher_ptr_id_cmp); |
901 | 919 | ||
902 | return(cipherstack); | 920 | return(cipherstack); |