From ded9d88dc0d6a1b6f80a72f55642d35963db9446 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 14 Aug 2019 15:18:40 -0300 Subject: [PATCH] Fixing small bugs in the API. --- src/selection/selection.c | 6 ++++-- src/ssl/linux/ldap.c | 13 +++++++++++-- src/testprogram/testprogram.c | 5 +++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/selection/selection.c b/src/selection/selection.c index ca8e3eb..c4076ec 100644 --- a/src/selection/selection.c +++ b/src/selection/selection.c @@ -288,7 +288,7 @@ LIB3270_EXPORT char * lib3270_get_string_at_address(H3270 *h, int offset, int le return NULL; } - maxlen = (h->rows * (h->cols+1)) - offset; + maxlen = (h->rows * (h->cols+ (lf ? 1 : 0) )) - offset; if(maxlen <= 0 || offset < 0) { errno = EINVAL; @@ -301,7 +301,9 @@ LIB3270_EXPORT char * lib3270_get_string_at_address(H3270 *h, int offset, int le buffer = lib3270_malloc(len+1); ptr = buffer; -// trace("len=%d buffer=%p",len,buffer); + memset(buffer,0,len+1); + + trace("len=%d buffer=%p",len,buffer); while(len > 0) { diff --git a/src/ssl/linux/ldap.c b/src/ssl/linux/ldap.c index ff43872..7109ce5 100644 --- a/src/ssl/linux/ldap.c +++ b/src/ssl/linux/ldap.c @@ -34,9 +34,18 @@ */ #include +#include +#include +#include +#include #if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LDAP) +#include +#include +#include +#include + #define LDAP_DEPRECATED 1 #include @@ -124,7 +133,7 @@ LIB3270_INTERNAL X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAG message->text = _( "Can't initialize LDAP" ); message->description = ldap_err2string(rc); lib3270_write_log(hSession,"ssl","%s: %s",url, message->description); - return -1; + return NULL; } unsigned long version = LDAP_VERSION3; @@ -146,7 +155,7 @@ LIB3270_INTERNAL X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAG message->text = _( "Can't bind to LDAP server" ); message->description = ldap_err2string(rc); lib3270_write_log(hSession,"ssl","%s: %s",url, message->description); - return -1; + return NULL; } lib3270_autoptr(LDAPMessage) results = NULL; diff --git a/src/testprogram/testprogram.c b/src/testprogram/testprogram.c index 1fd0156..a5b01c9 100644 --- a/src/testprogram/testprogram.c +++ b/src/testprogram/testprogram.c @@ -89,6 +89,11 @@ int main(int argc, char *argv[]) if(!rc) { lib3270_wait_for_ready(h,10); + + lib3270_autoptr(char) text = lib3270_get_string_at_address(h,0,-1,0); + if(text) + printf("Screen:\n[%s]\n",text); + lib3270_enter(h); lib3270_wait_for_ready(h,10); } -- libgit2 0.21.2