diff options
Diffstat (limited to 'src/lib/libssl/ssl_cert.c')
-rw-r--r-- | src/lib/libssl/ssl_cert.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/lib/libssl/ssl_cert.c b/src/lib/libssl/ssl_cert.c index 3d31bbf05f..da90078a37 100644 --- a/src/lib/libssl/ssl_cert.c +++ b/src/lib/libssl/ssl_cert.c | |||
@@ -781,7 +781,7 @@ err: | |||
781 | #endif | 781 | #endif |
782 | #endif | 782 | #endif |
783 | 783 | ||
784 | #else | 784 | #else /* OPENSSL_SYS_WIN32 */ |
785 | 785 | ||
786 | int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | 786 | int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, |
787 | const char *dir) | 787 | const char *dir) |
@@ -789,10 +789,30 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | |||
789 | WIN32_FIND_DATA FindFileData; | 789 | WIN32_FIND_DATA FindFileData; |
790 | HANDLE hFind; | 790 | HANDLE hFind; |
791 | int ret = 0; | 791 | int ret = 0; |
792 | #ifdef OPENSSL_SYS_WINCE | ||
793 | WCHAR* wdir = NULL; | ||
794 | #endif | ||
792 | 795 | ||
793 | CRYPTO_w_lock(CRYPTO_LOCK_READDIR); | 796 | CRYPTO_w_lock(CRYPTO_LOCK_READDIR); |
794 | 797 | ||
798 | #ifdef OPENSSL_SYS_WINCE | ||
799 | /* convert strings to UNICODE */ | ||
800 | { | ||
801 | BOOL result = FALSE; | ||
802 | int i; | ||
803 | wdir = malloc((strlen(dir)+1)*2); | ||
804 | if (wdir == NULL) | ||
805 | goto err_noclose; | ||
806 | for (i=0; i<(int)strlen(dir)+1; i++) | ||
807 | wdir[i] = (short)dir[i]; | ||
808 | } | ||
809 | #endif | ||
810 | |||
811 | #ifdef OPENSSL_SYS_WINCE | ||
812 | hFind = FindFirstFile(wdir, &FindFileData); | ||
813 | #else | ||
795 | hFind = FindFirstFile(dir, &FindFileData); | 814 | hFind = FindFirstFile(dir, &FindFileData); |
815 | #endif | ||
796 | /* Note that a side effect is that the CAs will be sorted by name */ | 816 | /* Note that a side effect is that the CAs will be sorted by name */ |
797 | if(hFind == INVALID_HANDLE_VALUE) | 817 | if(hFind == INVALID_HANDLE_VALUE) |
798 | { | 818 | { |
@@ -807,7 +827,11 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | |||
807 | char buf[1024]; | 827 | char buf[1024]; |
808 | int r; | 828 | int r; |
809 | 829 | ||
830 | #ifdef OPENSSL_SYS_WINCE | ||
831 | if(strlen(dir)+_tcslen(FindFileData.cFileName)+2 > sizeof buf) | ||
832 | #else | ||
810 | if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf) | 833 | if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf) |
834 | #endif | ||
811 | { | 835 | { |
812 | SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG); | 836 | SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG); |
813 | goto err; | 837 | goto err; |
@@ -825,6 +849,10 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | |||
825 | err: | 849 | err: |
826 | FindClose(hFind); | 850 | FindClose(hFind); |
827 | err_noclose: | 851 | err_noclose: |
852 | #ifdef OPENSSL_SYS_WINCE | ||
853 | if (wdir != NULL) | ||
854 | free(wdir); | ||
855 | #endif | ||
828 | CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); | 856 | CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); |
829 | return ret; | 857 | return ret; |
830 | } | 858 | } |