[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openssl-dev
Subject:    Re: [openssl.org #3479] BIO_read_filename() does not handle UTF-8 on Windows, as BIO_new_file() does
From:       "David Woodhouse via RT" <rt () openssl ! org>
Date:       2014-07-31 14:24:22
Message-ID: rt-4.0.4-31294-1406816662-373.3479-6-0 () openssl ! org
[Download RAW message or body]

Oops, it's probably a good idea to actually remember to add 'return
file;' at the end of the new function as I had intended, not just rely
on the value being left in the appropriate register after the fopen()
call.

diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c
index b954fe7..7765584 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
+	return file;
+}
+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


["smime.p7s" (application/x-pkcs7-signature)]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           majordomo@openssl.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic