提交 ff03599a 编写于 作者: D David Woodhouse 提交者: Rich Salz

RT3479: Add UTF8 support to BIO_read_filename()

If we use BIO_new_file(), on Windows it'll jump through hoops to work
around their unusual 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?

It would certainly be nice if SSL_use_certificate_chain_file() worked.

Also made BIO_C_SET_FILENAME work (rsalz)
Signed-off-by: NRich Salz <rsalz@akamai.com>
Reviewed-by: NAndy Polyakov <appro@openssl.org>
上级 4cd94416
...@@ -115,9 +115,8 @@ static BIO_METHOD methods_filep = { ...@@ -115,9 +115,8 @@ static BIO_METHOD methods_filep = {
NULL, NULL,
}; };
BIO *BIO_new_file(const char *filename, const char *mode) static FILE *file_fopen(const char *filename, const char *mode)
{ {
BIO *ret;
FILE *file = NULL; FILE *file = NULL;
# if defined(_WIN32) && defined(CP_UTF8) # if defined(_WIN32) && defined(CP_UTF8)
...@@ -164,6 +163,14 @@ BIO *BIO_new_file(const char *filename, const char *mode) ...@@ -164,6 +163,14 @@ BIO *BIO_new_file(const char *filename, const char *mode)
# else # else
file = fopen(filename, mode); file = fopen(filename, mode);
# endif # endif
return (file);
}
BIO *BIO_new_file(const char *filename, const char *mode)
{
BIO *ret;
FILE *file = file_fopen(filename, mode);
if (file == NULL) { if (file == NULL) {
SYSerr(SYS_F_FOPEN, get_last_sys_error()); SYSerr(SYS_F_FOPEN, get_last_sys_error());
ERR_add_error_data(5, "fopen('", filename, "','", mode, "')"); ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
...@@ -386,7 +393,7 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) ...@@ -386,7 +393,7 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
else else
strcat(p, "t"); strcat(p, "t");
# endif # endif
fp = fopen(ptr, p); fp = file_fopen(ptr, p);
if (fp == NULL) { if (fp == NULL) {
SYSerr(SYS_F_FOPEN, get_last_sys_error()); SYSerr(SYS_F_FOPEN, get_last_sys_error());
ERR_add_error_data(5, "fopen('", ptr, "','", p, "')"); ERR_add_error_data(5, "fopen('", ptr, "','", p, "')");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册