On Thu, 2014-07-31 at 08:50 +0200, David Woodhouse via RT wrote:
> If we use BIO_new_file(), on Windows it'll jump through hoops to work
> around their brain-damaged charset/Unicode handling — it'll convert a
> UTF-8 filename to UCS-16LE and attempt to use _wfopen().
> 
> If you use BIO_read_filename(), it doesn't do this. Shouldn't it be
> consistent?

Fixed thus (tested by reverting
http://git.infradead.org/users/dwmw2/openconnect.git/commitdiff/92f3ce57a and 
observing the failure, then retesting with patched OpenSSL and observing it 
work).

diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c
index b954fe7..4591740 100644
--- a/crypto/bio/bss_file.c
+++ b/crypto/bio/bss_file.c
@@ -116,9 +116,8 @@ static BIO_METHOD methods_filep=
        NULL,
        };
 
-BIO *BIO_new_file(const char *filename, const char *mode)
-       {
-       BIO  *ret;
+static FILE *file_fopen(const char *filename, const char *mode)
+{
        FILE *file=NULL;
 
 #if defined(_WIN32) && defined(CP_UTF8)
@@ -164,6 +163,13 @@ BIO *BIO_new_file(const char *filename, const char *mode)
 #else
        file=fopen(filename,mode);      
 #endif
+
+}
+BIO *BIO_new_file(const char *filename, const char *mode)
+       {
+       BIO  *ret;
+       FILE *file=file_fopen(filename, mode);
+
        if (file == NULL)
                {
                SYSerr(SYS_F_FOPEN,get_last_sys_error());
@@ -392,7 +398,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long 
num, void *ptr)
                else
                        strcat(p,"t");
 #endif
-               fp=fopen(ptr,p);
+               fp=file_fopen(ptr,p);
                if (fp == NULL)
                        {
                        SYSerr(SYS_F_FOPEN,get_last_sys_error());


-- 
dwmw2

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to