From 0c86c0a330d6c89c09a73345d0366361d28b3a12 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 3 Aug 2020 22:52:01 -0300 Subject: [PATCH] Fixing windows build. --- src/include/internals.h | 2 ++ src/ssl/notify.c | 18 ++++++++++-------- src/ssl/windows/http.c | 2 +- src/ssl/windows/ldap.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------ 4 files changed, 78 insertions(+), 51 deletions(-) diff --git a/src/include/internals.h b/src/include/internals.h index 23a0e5a..558ed1e 100644 --- a/src/include/internals.h +++ b/src/include/internals.h @@ -801,6 +801,8 @@ LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on); DWORD lasterror; #endif // _WIN32 + const char *body; + const LIB3270_POPUP *popup; /// @brief Pointer to popup message. } SSL_ERROR_MESSAGE; diff --git a/src/ssl/notify.c b/src/ssl/notify.c index c9071bd..3966812 100644 --- a/src/ssl/notify.c +++ b/src/ssl/notify.c @@ -59,14 +59,16 @@ static LIB3270_POPUP * translate_ssl_error_message(const SSL_ERROR_MESSAGE *msg, printf("\n\nMSG-CODE=%d\n\n",msg->code); + const char *body = (msg->body ? msg->body : msg->popup->body); + if(msg->code) { - if(msg->popup->body) + if(body) { popup = lib3270_popup_clone_printf( msg->popup, _( "%s\nThe SSL error message was \"%s\"(%d)" ), - dgettext(GETTEXT_PACKAGE,msg->popup->body), + dgettext(GETTEXT_PACKAGE,body), ERR_reason_error_string(msg->code), msg->code ); @@ -87,12 +89,12 @@ static LIB3270_POPUP * translate_ssl_error_message(const SSL_ERROR_MESSAGE *msg, { lib3270_autoptr(char) windows_error = lib3270_win32_translate_error_code(msg->lasterror); - if(msg->popup->body) + if(body) { popup = lib3270_popup_clone_printf( msg->popup, _( "%s\nThe windows error was \"%s\" (%u)" ), - dgettext(GETTEXT_PACKAGE,msg->popup->body), + dgettext(GETTEXT_PACKAGE,body), windows_error, (unsigned int) msg->lasterror ); @@ -111,12 +113,12 @@ static LIB3270_POPUP * translate_ssl_error_message(const SSL_ERROR_MESSAGE *msg, #endif // _WIN32 else if(rc) { - if(msg->popup->body) + if(body) { popup = lib3270_popup_clone_printf( msg->popup, _( "%s\nThe operating system error was \"%s\" (%u)" ), - dgettext(GETTEXT_PACKAGE,msg->popup->body), + dgettext(GETTEXT_PACKAGE,body), strerror(rc), rc ); @@ -137,8 +139,8 @@ static LIB3270_POPUP * translate_ssl_error_message(const SSL_ERROR_MESSAGE *msg, popup = lib3270_malloc(sizeof(LIB3270_POPUP)); *popup = *msg->popup; - if(msg->popup->body) - popup->body = dgettext(GETTEXT_PACKAGE,msg->popup->body); + if(body) + popup->body = dgettext(GETTEXT_PACKAGE,body); } diff --git a/src/ssl/windows/http.c b/src/ssl/windows/http.c index e48db64..622e8c2 100644 --- a/src/ssl/windows/http.c +++ b/src/ssl/windows/http.c @@ -59,7 +59,7 @@ X509_CRL * get_crl_using_http(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons }; popup.body = error_message; - message->popup = error_message; + message->popup = &popup; message->code = hSession->ssl.error = 0; trace_ssl( hSession,"Can't get %s: %s\n", diff --git a/src/ssl/windows/ldap.c b/src/ssl/windows/ldap.c index 4c56c17..2870ccc 100644 --- a/src/ssl/windows/ldap.c +++ b/src/ssl/windows/ldap.c @@ -104,11 +104,14 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons if(!base) { - message->error = hSession->ssl.error = 0; - message->title = _( "Security error" ); - message->text = _( "No DN of the entry at which to start the search on the URL" ); - message->description = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ); - debug("%s",message->text); + static const LIB3270_POPUP popup = { + .summary = N_( "No DN of the entry at which to start the search on the URL" ), + .body = N_( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ) + }; + + message->code = hSession->ssl.error = 0; + message->popup = &popup; + debug("%s",message->popup->summary); errno = EINVAL; return NULL; } @@ -118,11 +121,14 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons if(!base) { - message->error = hSession->ssl.error = 0; - message->title = _( "Security error" ); - message->text = _( "No LDAP attribute on the URL" ); - message->description = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ); - debug("%s",message->text); + static const LIB3270_POPUP popup = { + .summary = N_( "No LDAP attribute on the URL" ), + .body = N_( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" ) + }; + + message->code = hSession->ssl.error = 0; + message->popup = &popup; + debug("%s",message->popup->summary); errno = EINVAL; return NULL; } @@ -147,12 +153,15 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons if(!ld) { - message->error = hSession->ssl.error = 0; - message->title = _( "Security error" ); - message->text = _( "Can't initialize LDAP" ); - debug("%s",message->text); + static const LIB3270_POPUP popup = { + .summary = N_( "Can't initialize LDAP" ) + }; + + message->code = hSession->ssl.error = 0; + message->popup = &popup; + + debug("%s",message->popup->summary); message->lasterror = GetLastError(); - message->description = NULL; errno = EINVAL; return NULL; } @@ -161,11 +170,13 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version); if(rc != LDAP_SUCCESS) { - message->error = hSession->ssl.error = 0; - message->title = _( "Security error" ); - message->text = _( "Can't set LDAP protocol version" ); + static const LIB3270_POPUP popup = { + .summary = N_( "Can't set LDAP protocol version" ) + }; + + message->code = hSession->ssl.error = 0; + message->popup = &popup; message->lasterror = LdapMapErrorToWin32(rc); - message->description = NULL; debug("%s (rc=%u, lasterror=%d)",ldap_err2string(rc),rc,(unsigned int) message->lasterror); @@ -176,11 +187,13 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons rc = ldap_simple_bind_s(ld, NULL, NULL); if(rc != LDAP_SUCCESS) { - message->error = hSession->ssl.error = 0; - message->title = _( "Security error" ); - message->text = _( "Can't bind to LDAP server" ); + static const LIB3270_POPUP popup = { + .summary = N_( "Can't bind to LDAP server" ) + }; + + message->code = hSession->ssl.error = 0; + message->popup = &popup; message->lasterror = LdapMapErrorToWin32(rc); - message->description = NULL; debug("%s (rc=%u, lasterror=%d)",ldap_err2string(rc),rc,(unsigned int) message->lasterror); @@ -206,11 +219,12 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons if(rc != LDAP_SUCCESS) { - message->error = hSession->ssl.error = 0; - message->title = _( "Security error" ); - message->text = _( "Can't search LDAP server" ); - message->description = ldap_err2string(rc); - lib3270_write_log(hSession,"ssl","%s: %s",url, message->description); + static const LIB3270_POPUP popup = { + .summary = N_( "Can't search LDAP server" ) + }; + message->body = ldap_err2string(rc); + message->popup = &popup; + lib3270_write_log(hSession,"ssl","%s: %s",url, message->body); return NULL; } @@ -218,11 +232,14 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons char __attribute__ ((__cleanup__(lib3270_autoptr_cleanup_LDAPPTR))) *attr = ldap_first_attribute(ld, results, &ber); if(!attr) { - message->error = hSession->ssl.error = 0; - message->title = _( "Security error" ); - message->text = _( "Can't get LDAP attribute" ); - message->description = _("Search did not produce any attributes."); - lib3270_write_log(hSession,"ssl","%s: %s",url, message->description); + static const LIB3270_POPUP popup = { + .summary = N_( "Can't get LDAP attribute" ), + .body = N_("Search did not produce any attributes.") + }; + + message->code = hSession->ssl.error = 0; + message->popup = &popup; + lib3270_write_log(hSession,"ssl","%s: %s",url, message->popup->body); errno = ENOENT; return NULL; } @@ -230,11 +247,13 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons struct berval ** value = ldap_get_values_len(ld, results, attr); if(!value) { - message->error = hSession->ssl.error = 0; - message->title = _( "Security error" ); - message->text = _( "Can't get LDAP attribute" ); - message->description = _("Search did not produce any values."); - lib3270_write_log(hSession,"ssl","%s: %s",url, message->description); + static const LIB3270_POPUP popup = { + .summary = N_( "Can't get LDAP attribute" ), + .body = N_("Search did not produce any values.") + }; + message->code = hSession->ssl.error = 0; + message->popup = &popup; + lib3270_write_log(hSession,"ssl","%s: %s",url, message->popup->body); errno = ENOENT; return NULL; } @@ -254,10 +273,14 @@ X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons if(!d2i_X509_CRL(&x509_crl, &crl_data, value[0]->bv_len)) { - message->error = hSession->ssl.error = ERR_get_error(); - message->title = _( "Security error" ); - message->text = _( "Can't decode certificate revocation list" ); - lib3270_write_log(hSession,"ssl","%s: %s",url, message->text); + static const LIB3270_POPUP popup = { + .summary = N_( "Can't decode certificate revocation list" ) + }; + + message->code = hSession->ssl.error = ERR_get_error(); + message->popup = &popup; + + lib3270_write_log(hSession,"ssl","%s: %s",url, message->popup->summary); ldap_value_free_len(value); return NULL; } -- libgit2 0.21.2