diff options
Diffstat (limited to 'src/lib/libcrypto/bio/bss_file.c')
-rw-r--r-- | src/lib/libcrypto/bio/bss_file.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index b954fe7ebc..8bfa0bcd97 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c | |||
@@ -123,7 +123,6 @@ BIO *BIO_new_file(const char *filename, const char *mode) | |||
123 | 123 | ||
124 | #if defined(_WIN32) && defined(CP_UTF8) | 124 | #if defined(_WIN32) && defined(CP_UTF8) |
125 | int sz, len_0 = (int)strlen(filename)+1; | 125 | int sz, len_0 = (int)strlen(filename)+1; |
126 | DWORD flags; | ||
127 | 126 | ||
128 | /* | 127 | /* |
129 | * Basically there are three cases to cover: a) filename is | 128 | * Basically there are three cases to cover: a) filename is |
@@ -137,22 +136,17 @@ BIO *BIO_new_file(const char *filename, const char *mode) | |||
137 | * ERROR_NO_UNICODE_TRANSLATION, in which case we fall | 136 | * ERROR_NO_UNICODE_TRANSLATION, in which case we fall |
138 | * back to fopen... | 137 | * back to fopen... |
139 | */ | 138 | */ |
140 | if ((sz=MultiByteToWideChar(CP_UTF8,(flags=MB_ERR_INVALID_CHARS), | 139 | if ((sz=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS, |
141 | filename,len_0,NULL,0))>0 || | ||
142 | (GetLastError()==ERROR_INVALID_FLAGS && | ||
143 | (sz=MultiByteToWideChar(CP_UTF8,(flags=0), | ||
144 | filename,len_0,NULL,0))>0) | 140 | filename,len_0,NULL,0))>0) |
145 | ) | ||
146 | { | 141 | { |
147 | WCHAR wmode[8]; | 142 | WCHAR wmode[8]; |
148 | WCHAR *wfilename = _alloca(sz*sizeof(WCHAR)); | 143 | WCHAR *wfilename = _alloca(sz*sizeof(WCHAR)); |
149 | 144 | ||
150 | if (MultiByteToWideChar(CP_UTF8,flags, | 145 | if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS, |
151 | filename,len_0,wfilename,sz) && | 146 | filename,len_0,wfilename,sz) && |
152 | MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1, | 147 | MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1, |
153 | wmode,sizeof(wmode)/sizeof(wmode[0])) && | 148 | wmode,sizeof(wmode)/sizeof(wmode[0])) && |
154 | (file=_wfopen(wfilename,wmode))==NULL && | 149 | (file=_wfopen(wfilename,wmode))==NULL && errno==ENOENT |
155 | (errno==ENOENT || errno==EBADF) | ||
156 | ) /* UTF-8 decode succeeded, but no file, filename | 150 | ) /* UTF-8 decode succeeded, but no file, filename |
157 | * could still have been locale-ized... */ | 151 | * could still have been locale-ized... */ |
158 | file = fopen(filename,mode); | 152 | file = fopen(filename,mode); |