On Thu, Apr 4, 2013 at 1:32 PM, Anton Malov <[email protected]> wrote:
>
> Actually I do not understand why can't be the buffer just printed to
> stderr since h=GetStdHandle(STD_ERROR_HANDLE) is used only for
> checking console mode i.e. stderr presence.
May be the patch can help
---
crypto/cryptlib.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index 56d82ad..dbeceed 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -299,23 +299,8 @@ int OPENSSL_isservice(void) { return 0; }
void OPENSSL_showfatal (const char *fmta,...)
{ va_list ap;
TCHAR buf[256];
- const TCHAR *fmt;
-#ifdef STD_ERROR_HANDLE /* what a dirty trick! */
- HANDLE h;
-
- if ((h=GetStdHandle(STD_ERROR_HANDLE)) != NULL &&
- GetFileType(h)!=FILE_TYPE_UNKNOWN)
- { /* must be console application */
- int len;
- DWORD out;
-
- va_start (ap,fmta);
- len=_vsnprintf((char *)buf,sizeof(buf),fmt,ap);
- WriteFile(h,buf,len<0?sizeof(buf):(DWORD)len,&out,NULL);
- va_end (ap);
- return;
- }
-#endif
+ const TCHAR *fmt = NULL;
+ HANDLE h = NULL;
if (sizeof(TCHAR)==sizeof(char))
fmt=(const TCHAR *)fmta;
@@ -350,6 +335,17 @@ void OPENSSL_showfatal (const char *fmta,...)
fmt = (const TCHAR *)fmtw;
} while (0);
+#ifdef STD_ERROR_HANDLE /* what a dirty trick! */
+ if ((h=GetStdHandle(STD_ERROR_HANDLE)) != NULL &&
+ h != INVALID_HANDLE_VALUE && GetFileType(h)!=FILE_TYPE_UNKNOWN)
+ { /* must be console application */
+ va_start (ap,fmta);
+ _vftprintf(stderr, fmt, ap);
+ va_end (ap);
+ return;
+ }
+#endif
+
va_start (ap,fmta);
_vsntprintf (buf,sizeof(buf)/sizeof(TCHAR)-1,fmt,ap);
buf [sizeof(buf)/sizeof(TCHAR)-1] = _T('\0');
@@ -358,8 +354,9 @@ void OPENSSL_showfatal (const char *fmta,...)
#if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
/* this -------------v--- guards NT-specific calls */
if (GetVersion() < 0x80000000 && OPENSSL_isservice() > 0)
- { HANDLE h = RegisterEventSource(0,_T("OPENSSL"));
- const TCHAR *pmsg=buf;
+ {
+ const TCHAR *pmsg = buf;
+ h = RegisterEventSource(0, _T("OPENSSL"));
ReportEvent(h,EVENTLOG_ERROR_TYPE,0,0,0,1,0,&pmsg,0);
DeregisterEventSource(h);
}
--
1.7.11.msysgit.1
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [email protected]
Automated List Manager [email protected]