Hello community, here is the log from the commit of package librelp for openSUSE:Factory checked in at 2020-06-23 20:59:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/librelp (Old) and /work/SRC/openSUSE:Factory/.librelp.new.2956 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "librelp" Tue Jun 23 20:59:52 2020 rev:38 rq:816326 version:1.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/librelp/librelp.changes 2020-03-03 10:14:51.474478751 +0100 +++ /work/SRC/openSUSE:Factory/.librelp.new.2956/librelp.changes 2020-06-23 21:00:05.200964525 +0200 @@ -1,0 +2,13 @@ +Thu Jun 18 13:54:50 UTC 2020 - Andreas Stieger <[email protected]> + +- librelp 1.6.0: + * fix namespace pollution + * replsess: fix double free of sendbuf in some cases + * improve support for libressl + * Modified GnuTLS priority according to standard crypto-policy + guideline + * tcp: Missing pUsr Copy to relpTcp Pointer fixed in + relpTcpAcceptConnReq + * report io errors for plain tcp connections + +------------------------------------------------------------------- Old: ---- librelp-1.5.0.tar.gz New: ---- librelp-1.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ librelp.spec ++++++ --- /var/tmp/diff_new_pack.WVDuem/_old 2020-06-23 21:00:06.760969789 +0200 +++ /var/tmp/diff_new_pack.WVDuem/_new 2020-06-23 21:00:06.768969815 +0200 @@ -18,7 +18,7 @@ %define library_name librelp0 Name: librelp -Version: 1.5.0 +Version: 1.6.0 Release: 0 Summary: A reliable logging library License: GPL-3.0-or-later ++++++ librelp-1.5.0.tar.gz -> librelp-1.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/librelp-1.5.0/ChangeLog new/librelp-1.6.0/ChangeLog --- old/librelp-1.5.0/ChangeLog 2020-01-14 10:22:50.000000000 +0100 +++ new/librelp-1.6.0/ChangeLog 2020-04-21 11:17:30.000000000 +0200 @@ -1,4 +1,37 @@ ---------------------------------------------------------------------- +Version 1.6.0 - 2020-04-21 +- fix namespace pollution - some non-API functions were exported + While fixing this, also some internal inconsistencies in function + visibility were fixed as well. + closes https://github.com/rsyslog/librelp/issues/179 +- replsess: fix double free of sendbuf in some cases. + In iRet handler of relpSessSendResponse, the sendbuf + was freed if iRet returned a failure. + However if error RELP_RET_IO_ERR happened in relpSendqAddBuf, + sendbuf was already assigned to relpSendqe_t. As a result + sendbuf was double freed in relpSendqDestruct. + see also + https://github.com/rsyslog/rsyslog/issues/4184 + https://github.com/rsyslog/rsyslog/issues/4005 + closes https://github.com/rsyslog/librelp/issues/183 +- improve support for libressl + LibreSSL has no support for @SECLEVEL and SSL_CONF_CTX_set_flags(). + LibreSSL is now detected and some functionality disabled if it is + used. + Thanks to Remi Locherer for the patch. +- Modified GnuTLS priority according to standard crypto-policy guideline + Edited TLS priority string default to conform to system-wide default + and align librelp behavior with other crypto-utilizing packages. + Note: this may be different from what the openSSL driver does. + Thanks to Jiri Vymazal for the patch. +- tcp: Missing pUsr Copy to relpTcp Pointer fixed in relpTcpAcceptConnReq + The userpointer was not copied into the relpTcp object. + Also fixed core dump crash in receive / send helpers when userpointer + is returned NULL from librelp. +- report io errors for plain tcp connections + this already happens with TLS, but not with plain tcp. Error messages + are a useful troubleshooting tool. +---------------------------------------------------------------------- Version 1.5.0 - 2020-01-14 - bugfix: too late termination of relp Engine on shutdown When librelp is instructed to shutdown, it processes messages diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/librelp-1.5.0/configure new/librelp-1.6.0/configure --- old/librelp-1.5.0/configure 2020-01-14 10:23:27.000000000 +0100 +++ new/librelp-1.6.0/configure 2020-04-21 11:18:13.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for librelp 1.5.0. +# Generated by GNU Autoconf 2.69 for librelp 1.6.0. # # Report bugs to <[email protected]>. # @@ -590,8 +590,8 @@ # Identity of this package. PACKAGE_NAME='librelp' PACKAGE_TARNAME='librelp' -PACKAGE_VERSION='1.5.0' -PACKAGE_STRING='librelp 1.5.0' +PACKAGE_VERSION='1.6.0' +PACKAGE_STRING='librelp 1.6.0' PACKAGE_BUGREPORT='[email protected]' PACKAGE_URL='' @@ -1368,7 +1368,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures librelp 1.5.0 to adapt to many kinds of systems. +\`configure' configures librelp 1.6.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1439,7 +1439,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of librelp 1.5.0:";; + short | recursive ) echo "Configuration of librelp 1.6.0:";; esac cat <<\_ACEOF @@ -1568,7 +1568,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -librelp configure 1.5.0 +librelp configure 1.6.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2094,7 +2094,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by librelp $as_me 1.5.0, which was +It was created by librelp $as_me 1.6.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2960,7 +2960,7 @@ # Define the identity of the package. PACKAGE='librelp' - VERSION='1.5.0' + VERSION='1.6.0' cat >>confdefs.h <<_ACEOF @@ -15321,7 +15321,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by librelp $as_me 1.5.0, which was +This file was extended by librelp $as_me 1.6.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15387,7 +15387,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -librelp config.status 1.5.0 +librelp config.status 1.6.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/librelp-1.5.0/configure.ac new/librelp-1.6.0/configure.ac --- old/librelp-1.5.0/configure.ac 2020-01-14 10:22:59.000000000 +0100 +++ new/librelp-1.6.0/configure.ac 2020-04-21 11:17:59.000000000 +0200 @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([librelp], [1.5.0], [[email protected]]) +AC_INIT([librelp], [1.6.0], [[email protected]]) # change to the one below if Travis has a timeout #AM_INIT_AUTOMAKE([subdir-objects serial-tests]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/librelp-1.5.0/src/Makefile.am new/librelp-1.6.0/src/Makefile.am --- old/librelp-1.5.0/src/Makefile.am 2019-03-04 10:03:06.000000000 +0100 +++ new/librelp-1.6.0/src/Makefile.am 2020-04-21 11:17:30.000000000 +0200 @@ -48,6 +48,6 @@ librelp_la_LIBADD = $(rt_libs) $(GNUTLS_LIBS) $(OPENSSL_LIBS) # info on version-info: # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -librelp_la_LDFLAGS = -version-info 5:0:5 -export-symbols-regex '^relp' +librelp_la_LDFLAGS = -version-info 5:0:5 -export-symbols-regex '^relp[^_]*$$' include_HEADERS = librelp.h diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/librelp-1.5.0/src/Makefile.in new/librelp-1.6.0/src/Makefile.in --- old/librelp-1.5.0/src/Makefile.in 2020-01-14 10:23:28.000000000 +0100 +++ new/librelp-1.6.0/src/Makefile.in 2020-04-21 11:18:14.000000000 +0200 @@ -378,7 +378,7 @@ librelp_la_LIBADD = $(rt_libs) $(GNUTLS_LIBS) $(OPENSSL_LIBS) # info on version-info: # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -librelp_la_LDFLAGS = -version-info 5:0:5 -export-symbols-regex '^relp' +librelp_la_LDFLAGS = -version-info 5:0:5 -export-symbols-regex '^relp[^_]*$$' include_HEADERS = librelp.h all: all-am diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/librelp-1.5.0/src/relpsess.c new/librelp-1.6.0/src/relpsess.c --- old/librelp-1.5.0/src/relpsess.c 2020-01-14 10:22:05.000000000 +0100 +++ new/librelp-1.6.0/src/relpsess.c 2020-04-21 11:17:30.000000000 +0200 @@ -329,10 +329,15 @@ callOnErr(pThis, "io error, session broken", RELP_RET_SESSION_BROKEN); pThis->pEngine->dbgprint("relp session %p is broken, io error\n", (void*)pThis); pThis->sessState = eRelpSessState_BROKEN; - } + } else { + /* alorbach, 2020-04-08: + * Only free sendbuf if error is not RELP_RET_IO_ERR! + * otherwise the buffer is double freed in relpSendbufDestruct() (sendbuf.c) + */ + if(pSendbuf != NULL) + relpSendbufDestruct(&pSendbuf); + } - if(pSendbuf != NULL) - relpSendbufDestruct(&pSendbuf); } LEAVE_RELPFUNC; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/librelp-1.5.0/src/tcp.c new/librelp-1.6.0/src/tcp.c --- old/librelp-1.5.0/src/tcp.c 2020-01-14 10:22:05.000000000 +0100 +++ new/librelp-1.6.0/src/tcp.c 2020-04-21 11:17:30.000000000 +0200 @@ -652,7 +652,7 @@ #if defined(ENABLE_TLS) -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpDestructTLS_gtls(relpTcp_t *pThis) { int sslRet; @@ -667,14 +667,14 @@ LEAVE_RELPFUNC; } #else -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpDestructTLS_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *pThis) { return RELP_RET_ERR_INTERNAL; } #endif /* defined(ENABLE_TLS) */ #if defined(ENABLE_TLS_OPENSSL) -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpDestructTLS_ossl(relpTcp_t *pThis) { ENTER_RELPFUNC; @@ -710,7 +710,7 @@ LEAVE_RELPFUNC; } #else -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpDestructTLS_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *pThis) { return RELP_RET_ERR_INTERNAL; @@ -1153,20 +1153,29 @@ char pristringBuf[4096]; char *pristring; ENTER_RELPFUNC; - /* Compute priority string (in simple cases where the user does not care...) */ + /* Set default priority string (in simple cases where the user does not care...) */ if(pThis->pristring == NULL) { - if(pThis->bEnableTLSZip) { - strncpy(pristringBuf, "NORMAL:+ANON-DH:+COMP-ALL", sizeof(pristringBuf)); - } else { - strncpy(pristringBuf, "NORMAL:+ANON-DH:+COMP-NULL", sizeof(pristringBuf)); + if (pThis->authmode == eRelpAuthMode_None) { + if(pThis->bEnableTLSZip) { + strncpy(pristringBuf, "NORMAL:+ANON-DH:+COMP-ALL", sizeof(pristringBuf)); + } else { + strncpy(pristringBuf, "NORMAL:+ANON-DH:+COMP-NULL", sizeof(pristringBuf)); } - pristringBuf[sizeof(pristringBuf)-1] = '\0'; - pristring = pristringBuf; + pristringBuf[sizeof(pristringBuf)-1] = '\0'; + pristring = pristringBuf; + r = gnutls_priority_set_direct(pThis->session, pristring, NULL); + } else { + r = gnutls_set_default_priority(pThis->session); + strncpy(pristringBuf, "to recommended system default", sizeof(pristringBuf)); + pristringBuf[sizeof(pristringBuf)-1] = '\0'; + pristring = pristringBuf; + } + } else { pristring = pThis->pristring; + r = gnutls_priority_set_direct(pThis->session, pristring, NULL); } - r = gnutls_priority_set_direct(pThis->session, pristring, NULL); if(r == GNUTLS_E_INVALID_REQUEST) { ABORT_FINALIZE(RELP_RET_INVLD_TLS_PRIO); } else if(r != GNUTLS_E_SUCCESS) { @@ -1182,7 +1191,7 @@ LEAVE_RELPFUNC; } #else /* #ifdef ENABLE_TLS */ -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpTLSSetPrio_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) { return RELP_RET_ERR_INTERNAL; @@ -1200,7 +1209,8 @@ /* Compute priority string (in simple cases where the user does not care...) */ if(pThis->pristring == NULL) { if (pThis->authmode == eRelpAuthMode_None) { - #if OPENSSL_VERSION_NUMBER >= 0x10100000L + #if OPENSSL_VERSION_NUMBER >= 0x10100000L \ + && !defined(LIBRESSL_VERSION_NUMBER) /* NOTE: do never use: +eNULL, it DISABLES encryption! */ strncpy(pristringBuf, "ALL:+COMPLEMENTOFDEFAULT:+ADH:+ECDH:+aNULL@SECLEVEL=0", sizeof(pristringBuf)); @@ -1296,7 +1306,7 @@ #endif #else /* #ifdef ENABLE_TLS */ -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpAcceptConnReqInitTLS_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpSrv_t *const pSrv) { return RELP_RET_ERR_INTERNAL; @@ -1502,7 +1512,7 @@ /* Perform all necessary actions for Handshake */ -relpRetVal +static relpRetVal relpTcpRtryHandshake_ossl(relpTcp_t *const pThis) { int res, resErr; @@ -1578,7 +1588,7 @@ } else { pThis->pEngine->dbgprint("relpTcpSetSslConfCmd_ossl: set to '%s'\n", tlsConfigCmd); char errmsg[1424]; -#if OPENSSL_VERSION_NUMBER >= 0x10020000L +#if OPENSSL_VERSION_NUMBER >= 0x10020000L && !defined(LIBRESSL_VERSION_NUMBER) char *pCurrentPos; char *pNextPos; char *pszCmd; @@ -1859,31 +1869,31 @@ return RELP_RET_ERR_INTERNAL; } -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpGetRtryDirection_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) { return RELP_RET_ERR_INTERNAL; } -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpRtryHandshake_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) { return RELP_RET_ERR_INTERNAL; } -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpLstnInitTLS_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) { return RELP_RET_ERR_INTERNAL; } -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpAcceptConnReqInitTLS_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpSrv_t *const pSrv) { return RELP_RET_ERR_INTERNAL; } -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpConnectTLSInit_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) { return RELP_RET_ERR_INTERNAL; @@ -2005,6 +2015,7 @@ /* construct our object so that we can use it... */ CHKRet(relpTcpConstruct(&pThis, pEngine, RELP_SRV_CONN, pSrv)); + pThis->pUsr = pSrv->pUsr; if(pSrv->bKeepAlive) EnableKeepAlive(pThis, pSrv, iNewSock); @@ -2649,7 +2660,7 @@ LEAVE_RELPFUNC; } #else /* #ifdef ENABLE_TLS */ -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpLstnInitTLS_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) { return RELP_RET_ERR_INTERNAL; @@ -2940,7 +2951,7 @@ /* -- first TLS-lib specific versions -- */ #if defined(ENABLE_TLS) -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpRcv_gtls(relpTcp_t *const pThis, relpOctet_t *const pRcvBuf, ssize_t *const pLenBuf) { ENTER_RELPFUNC; @@ -2964,7 +2975,7 @@ LEAVE_RELPFUNC; } #else -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpRcv_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpOctet_t *const pRcvBuf, LIBRELP_ATTR_UNUSED ssize_t *const pLenBuf) { @@ -2972,7 +2983,7 @@ } #endif /* defined(ENABLE_TLS) */ #if defined(ENABLE_TLS_OPENSSL) -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpRcv_ossl(relpTcp_t *const pThis, relpOctet_t *const pRcvBuf, ssize_t *const pLenBuf) { ENTER_RELPFUNC; @@ -3008,7 +3019,7 @@ LEAVE_RELPFUNC; } #else -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpRcv_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpOctet_t *const pRcvBuf, LIBRELP_ATTR_UNUSED ssize_t *const pLenBuf) { @@ -3094,7 +3105,7 @@ /* -- first TLS-lib specific versions -- */ #if defined(ENABLE_TLS) -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpSend_gtls(relpTcp_t *const pThis, relpOctet_t *const pBuf, ssize_t *const pLenBuf) { ssize_t written; @@ -3119,7 +3130,7 @@ LEAVE_RELPFUNC; } #else -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpSend_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpOctet_t *const pBuf, LIBRELP_ATTR_UNUSED ssize_t *const pLenBuf) { @@ -3127,7 +3138,7 @@ } #endif /* defined(ENABLE_TLS) */ #if defined(ENABLE_TLS_OPENSSL) -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpSend_ossl(relpTcp_t *const pThis, relpOctet_t *const pBuf, ssize_t *const pLenBuf) { ssize_t written; @@ -3167,7 +3178,7 @@ LEAVE_RELPFUNC; } #else -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpSend_ossl(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED relpOctet_t *const pBuf, LIBRELP_ATTR_UNUSED ssize_t *const pLenBuf) { @@ -3207,8 +3218,15 @@ /* this is fine, just retry... */ written = 0; break; - default: + default: { + char msgbuf[900]; + char errStr[800]; + _relpEngine_strerror_r(errno, errStr, sizeof(errStr)); + snprintf(msgbuf, sizeof(msgbuf), "error sending relp: %s", errStr); + msgbuf[sizeof(msgbuf)-1] = '\0'; + callOnErr(pThis, msgbuf, RELP_RET_IO_ERR); ABORT_FINALIZE(RELP_RET_IO_ERR); + } break; } } @@ -3348,7 +3366,7 @@ #endif #else /* #ifdef ENABLE_TLS */ -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpConnectTLSInit_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) { return RELP_RET_ERR_INTERNAL; @@ -3564,7 +3582,7 @@ #endif /* #ifdef ENABLE_TLS */ #ifdef ENABLE_TLS -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpRtryHandshake_gtls(relpTcp_t *const pThis) { int r; @@ -3586,7 +3604,7 @@ LEAVE_RELPFUNC; } #else /* #ifdef ENABLE_TLS */ -relpRetVal LIBRELP_ATTR_NONNULL() +static relpRetVal LIBRELP_ATTR_NONNULL() relpTcpRtryHandshake_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) { return RELP_RET_ERR_INTERNAL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/librelp-1.5.0/tests/receive.c new/librelp-1.6.0/tests/receive.c --- old/librelp-1.5.0/tests/receive.c 2020-01-14 10:22:06.000000000 +0100 +++ new/librelp-1.6.0/tests/receive.c 2020-04-21 11:17:30.000000000 +0200 @@ -158,14 +158,18 @@ onErr(void *pUsr, char *objinfo, char* errmesg, LIBRELP_ATTR_UNUSED relpRetVal errcode) { struct usrdata *pThis = (struct usrdata*) pUsr; - if(pUsr != userdata) { - fprintf(stderr, "receive: pUsr NOT pointing to usrdata!\n"); - } - if(pThis->magic != USR_MAGIC) { - fprintf(stderr, "receive: pUsr magic incorrect in onErr, magic %8.8x " - "pUsr %p\n", pThis->magic, (void*) pThis); + if(pUsr != NULL) { + if(pUsr != userdata) { + fprintf(stderr, "receive: pUsr %p NOT pointing to userdata %p!\n", pUsr, (void*)userdata); + } + if(pThis->magic != USR_MAGIC) { + fprintf(stderr, "receive: pUsr magic incorrect in onErr, magic %8.8x " + "pUsr %p\n", pThis->magic, (void*) pThis); + } + fprintf(stderr, "%s: error '%s', object '%s'\n", pThis->progname, errmesg, objinfo); + } else { + fprintf(stderr, "receive: [pUsr==NULL] error '%s', object '%s'\n", errmesg, objinfo); } - fprintf(stderr, "%s: error '%s', object '%s'\n", pThis->progname, errmesg, objinfo); if(errFile != NULL) { fprintf(errFile, "receive: error '%s', object '%s'\n", errmesg, objinfo); } @@ -406,11 +410,13 @@ TRY(relpEngineSetDnsLookupMode(pRelpEngine, 0)); /* 0=disable */ TRY(relpEngineListnerConstruct(pRelpEngine, &pRelpSrv)); - TRY(relpSrvSetLstnPort(pRelpSrv, port)); + // Create userdata pointer as soon as possible for error callbacks userdata = calloc(1, sizeof(struct usrdata)); userdata->magic = USR_MAGIC; userdata->progname = strdup("receive"); relpSrvSetUsrPtr(pRelpSrv, userdata); + + TRY(relpSrvSetLstnPort(pRelpSrv, port)); if(maxDataSize != 0) { TRY(relpSrvSetMaxDataSize(pRelpSrv, maxDataSize)); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/librelp-1.5.0/tests/send.c new/librelp-1.6.0/tests/send.c --- old/librelp-1.5.0/tests/send.c 2020-01-14 10:22:06.000000000 +0100 +++ new/librelp-1.6.0/tests/send.c 2020-04-21 11:17:30.000000000 +0200 @@ -92,14 +92,19 @@ onErr(void *pUsr, char *objinfo, char* errmesg, LIBRELP_ATTR_UNUSED relpRetVal errcode) { struct usrdata *pThis = (struct usrdata*) pUsr; - if(pUsr != userdata) { - fprintf(stderr, "send: pUsr NOT pointing to usrdata!\n"); - } - if(pThis->magic != USR_MAGIC) { - fprintf(stderr, "send: pUsr magic incorrect in onErr, magic %8.8x " - "pUsr %p\n", pThis->magic, (void*) pThis); + if(pUsr != NULL) { + if(pUsr != userdata) { + fprintf(stderr, "send: pUsr %p NOT pointing to userdata %p!\n", pUsr, (void*)userdata); + } + if(pThis->magic != USR_MAGIC) { + fprintf(stderr, "send: pUsr magic incorrect in onErr, magic %8.8x " + "pUsr %p\n", pThis->magic, (void*) pThis); + } + printf("%s: error '%s', object '%s'\n", pThis->progname, errmesg, objinfo); + } else { + fprintf(stderr, "send: [pUsr==NULL] error '%s', object '%s'\n", errmesg, objinfo); } - printf("%s: error '%s', object '%s'\n", pThis->progname, errmesg, objinfo); + if(errFile != NULL) { fprintf(errFile, "send: error '%s', object '%s'\n", errmesg, objinfo); } @@ -410,12 +415,13 @@ TRY(relpEngineSetEnableCmd(pRelpEngine, (unsigned char*)"syslog", eRelpCmdState_Required)); TRY(relpEngineCltConstruct(pRelpEngine, &pRelpClt)); - TRY(relpCltSetTimeout(pRelpClt, timeout)); + // Create userdata pointer as soon as possible for error callbacks userdata = calloc(1, sizeof(struct usrdata)); userdata->magic = USR_MAGIC; userdata->progname = strdup("send"); TRY(relpCltSetUsrPtr(pRelpClt, userdata)); + TRY(relpCltSetTimeout(pRelpClt, timeout)); if(bEnableTLS) { TRY(relpCltEnableTLS(pRelpClt)); TRY(relpCltSetTlsConfigCmd(pRelpClt, tlsConfigCmd));
