[openssl-commits] [openssl] OpenSSL_1_0_1-stable update

Rich Salz rsalz at openssl.org
Mon Sep 21 18:36:54 UTC 2015


The branch OpenSSL_1_0_1-stable has been updated
       via  f9394bd7a053aa5ede7722e93b9351f8d9a800e7 (commit)
      from  b2a6718819cc29be0abdf9272a037f82317ed163 (commit)


- Log -----------------------------------------------------------------
commit f9394bd7a053aa5ede7722e93b9351f8d9a800e7
Author: Gunnar Kudrjavets <gunnarku at microsoft.com>
Date:   Mon Apr 27 11:14:45 2015 -0700

    RT3823: Improve the robustness of event logging
    
    There are a couple of minor fixes here:
    
    1) Handle the case when RegisterEventSource() fails (which it may for
    various reasons) and do the work of logging the event only if it succeeds.
    
    2) Handle the case when ReportEvent() fails and do our best in debug builds
    to at least attempt somehow indicate that something has gone wrong. The
    typical situation would be someone running tools like DbMon, DBWin32,
    DebugView or just having the debugger attached. The intent is to make sure
    that at least some data will be captured so that we can save hours and days
    of debugging time.
    
    3) Minor fix to change the MessageBox() flag to MB_ICONERROR. Though the
    value of MB_ICONERROR is the same value as MB_ICONSTOP, the intent is
    better conveyed by using MB_ICONERROR.
    
    Testing performed:
    
    1) Clean compilation for debug-VC-WIN32 and VC-WIN32.
    
    2) Good test results (nmake -f ms\ntdll.mak test) for debug-VC-WIN32 and
    VC-WIN32.
    
    3) Stepped through relevant changes using WinDBG and exercised the impacted
    code paths.
    
    Signed-off-by: Rich Salz <rsalz at akamai.com>
    Reviewed-by: Matt Caswell <matt at openssl.org>
    (cherry picked from commit 4cd94416a452c3a3e0df24c297f7d2f0e6d5bb5f)

-----------------------------------------------------------------------

Summary of changes:
 crypto/cryptlib.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index c654a5c..eccee72 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -930,13 +930,29 @@ void OPENSSL_showfatal(const char *fmta, ...)
 # if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
     /* this -------------v--- guards NT-specific calls */
     if (check_winnt() && OPENSSL_isservice() > 0) {
-        HANDLE h = RegisterEventSource(0, _T("OPENSSL"));
-        const TCHAR *pmsg = buf;
-        ReportEvent(h, EVENTLOG_ERROR_TYPE, 0, 0, 0, 1, 0, &pmsg, 0);
-        DeregisterEventSource(h);
+        HANDLE hEventLog = RegisterEventSource(NULL, _T("OpenSSL"));
+
+        if (hEventLog != NULL) {
+            const TCHAR *pmsg = buf;
+
+            if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, 0, 0, NULL,
+                             1, 0, &pmsg, NULL)) {
+#if defined(DEBUG)
+                /*
+                 * We are in a situation where we tried to report a critical
+                 * error and this failed for some reason. As a last resort,
+                 * in debug builds, send output to the debugger or any other
+                 * tool like DebugView which can monitor the output.
+                 */
+                OutputDebugString(pmsg);
+#endif
+            }
+
+            (void)DeregisterEventSource(hEventLog);
+        }
     } else
 # endif
-        MessageBox(NULL, buf, _T("OpenSSL: FATAL"), MB_OK | MB_ICONSTOP);
+        MessageBox(NULL, buf, _T("OpenSSL: FATAL"), MB_OK | MB_ICONERROR);
 }
 #else
 void OPENSSL_showfatal(const char *fmta, ...)


More information about the openssl-commits mailing list