diff options
Diffstat (limited to 'src/lib/libcrypto/bio/bss_file.c')
-rw-r--r-- | src/lib/libcrypto/bio/bss_file.c | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index 982317b34a..59e48e6659 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c | |||
@@ -89,10 +89,6 @@ | |||
89 | #include "bio_lcl.h" | 89 | #include "bio_lcl.h" |
90 | #include <openssl/err.h> | 90 | #include <openssl/err.h> |
91 | 91 | ||
92 | #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) | ||
93 | #include <nwfileio.h> | ||
94 | #endif | ||
95 | |||
96 | #if !defined(OPENSSL_NO_STDIO) | 92 | #if !defined(OPENSSL_NO_STDIO) |
97 | 93 | ||
98 | static int file_write(BIO *h, const char *buf, int num); | 94 | static int file_write(BIO *h, const char *buf, int num); |
@@ -122,46 +118,8 @@ BIO | |||
122 | BIO *ret; | 118 | BIO *ret; |
123 | FILE *file = NULL; | 119 | FILE *file = NULL; |
124 | 120 | ||
125 | #if defined(_WIN32) && defined(CP_UTF8) | ||
126 | int sz, len_0 = (int)strlen(filename) + 1; | ||
127 | DWORD flags; | ||
128 | |||
129 | /* | ||
130 | * Basically there are three cases to cover: a) filename is | ||
131 | * pure ASCII string; b) actual UTF-8 encoded string and | ||
132 | * c) locale-ized string, i.e. one containing 8-bit | ||
133 | * characters that are meaningful in current system locale. | ||
134 | * If filename is pure ASCII or real UTF-8 encoded string, | ||
135 | * MultiByteToWideChar succeeds and _wfopen works. If | ||
136 | * filename is locale-ized string, chances are that | ||
137 | * MultiByteToWideChar fails reporting | ||
138 | * ERROR_NO_UNICODE_TRANSLATION, in which case we fall | ||
139 | * back to fopen... | ||
140 | */ | ||
141 | if ((sz = MultiByteToWideChar(CP_UTF8,(flags = MB_ERR_INVALID_CHARS), | ||
142 | filename, len_0, NULL, 0)) > 0 || | ||
143 | (GetLastError() == ERROR_INVALID_FLAGS && | ||
144 | (sz = MultiByteToWideChar(CP_UTF8,(flags = 0), | ||
145 | filename, len_0, NULL, 0)) > 0)) { | ||
146 | WCHAR wmode[8]; | ||
147 | WCHAR *wfilename = _alloca(sz*sizeof(WCHAR)); | ||
148 | |||
149 | if (MultiByteToWideChar(CP_UTF8, flags, filename, len_0, | ||
150 | wfilename, sz) && MultiByteToWideChar(CP_UTF8, 0, mode, | ||
151 | strlen(mode) + 1, wmode, | ||
152 | sizeof(wmode) / sizeof(wmode[0])) && | ||
153 | (file = _wfopen(wfilename, wmode)) == NULL && | ||
154 | (errno == ENOENT || errno == EBADF) | ||
155 | ) /* UTF - 8 decode succeeded, but no file, filename | ||
156 | * could still have been locale-ized... */ | ||
157 | file = fopen(filename, mode); | ||
158 | } else if (GetLastError() == ERROR_NO_UNICODE_TRANSLATION) { | ||
159 | file = fopen(filename, mode); | ||
160 | } | ||
161 | #else | ||
162 | file = fopen(filename, mode); | 121 | file = fopen(filename, mode); |
163 | 122 | ||
164 | #endif | ||
165 | if (file == NULL) { | 123 | if (file == NULL) { |
166 | SYSerr(SYS_F_FOPEN, errno); | 124 | SYSerr(SYS_F_FOPEN, errno); |
167 | ERR_add_error_data(5, "fopen('", filename, "', '", mode, "')"); | 125 | ERR_add_error_data(5, "fopen('", filename, "', '", mode, "')"); |
@@ -304,9 +262,6 @@ file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
304 | b->ptr = ptr; | 262 | b->ptr = ptr; |
305 | b->init = 1; | 263 | b->init = 1; |
306 | #if BIO_FLAGS_UPLINK!=0 | 264 | #if BIO_FLAGS_UPLINK!=0 |
307 | #if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES) | ||
308 | #define _IOB_ENTRIES 20 | ||
309 | #endif | ||
310 | #if defined(_IOB_ENTRIES) | 265 | #if defined(_IOB_ENTRIES) |
311 | /* Safety net to catch purely internal BIO_set_fp calls */ | 266 | /* Safety net to catch purely internal BIO_set_fp calls */ |
312 | if ((size_t)ptr >= (size_t)stdin && | 267 | if ((size_t)ptr >= (size_t)stdin && |
@@ -317,37 +272,7 @@ file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
317 | #ifdef UP_fsetmod | 272 | #ifdef UP_fsetmod |
318 | if (b->flags&BIO_FLAGS_UPLINK) | 273 | if (b->flags&BIO_FLAGS_UPLINK) |
319 | UP_fsetmod(b->ptr,(char)((num&BIO_FP_TEXT)?'t':'b')); | 274 | UP_fsetmod(b->ptr,(char)((num&BIO_FP_TEXT)?'t':'b')); |
320 | else | ||
321 | #endif | 275 | #endif |
322 | { | ||
323 | #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) | ||
324 | int fd = fileno((FILE*)ptr); | ||
325 | /* Under CLib there are differences in file modes */ | ||
326 | if (num & BIO_FP_TEXT) | ||
327 | setmode(fd, O_TEXT); | ||
328 | else | ||
329 | setmode(fd, O_BINARY); | ||
330 | #elif defined(OPENSSL_SYS_MSDOS) | ||
331 | int fd = fileno((FILE*)ptr); | ||
332 | /* Set correct text/binary mode */ | ||
333 | if (num & BIO_FP_TEXT) | ||
334 | _setmode(fd, _O_TEXT); | ||
335 | /* Dangerous to set stdin/stdout to raw (unless redirected) */ | ||
336 | else { | ||
337 | if (fd == STDIN_FILENO || fd == STDOUT_FILENO) { | ||
338 | if (isatty(fd) <= 0) | ||
339 | _setmode(fd, _O_BINARY); | ||
340 | } else | ||
341 | _setmode(fd, _O_BINARY); | ||
342 | } | ||
343 | #elif defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN) | ||
344 | int fd = fileno((FILE*)ptr); | ||
345 | if (num & BIO_FP_TEXT) | ||
346 | setmode(fd, O_TEXT); | ||
347 | else | ||
348 | setmode(fd, O_BINARY); | ||
349 | #endif | ||
350 | } | ||
351 | break; | 276 | break; |
352 | case BIO_C_SET_FILENAME: | 277 | case BIO_C_SET_FILENAME: |
353 | file_free(b); | 278 | file_free(b); |
@@ -367,18 +292,6 @@ file_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
367 | ret = 0; | 292 | ret = 0; |
368 | break; | 293 | break; |
369 | } | 294 | } |
370 | #if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_WIN32_CYGWIN) | ||
371 | if (!(num & BIO_FP_TEXT)) | ||
372 | strcat(p, "b"); | ||
373 | else | ||
374 | strcat(p, "t"); | ||
375 | #endif | ||
376 | #if defined(OPENSSL_SYS_NETWARE) | ||
377 | if (!(num & BIO_FP_TEXT)) | ||
378 | strcat(p, "b"); | ||
379 | else | ||
380 | strcat(p, "t"); | ||
381 | #endif | ||
382 | fp = fopen(ptr, p); | 295 | fp = fopen(ptr, p); |
383 | if (fp == NULL) { | 296 | if (fp == NULL) { |
384 | SYSerr(SYS_F_FOPEN, errno); | 297 | SYSerr(SYS_F_FOPEN, errno); |