Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 1 | From 6e9b27f04132287463c89d3be0ce4f506944920d Mon Sep 17 00:00:00 2001 |
| 2 | From: Patrick Williams <patrick@stwcx.xyz> |
| 3 | Date: Fri, 3 Feb 2023 16:11:29 -0600 |
| 4 | Subject: [PATCH] tcp: fix some compiler warnings with enable-tls-openssl |
| 5 | |
| 6 | When --enable-tls=no and --enable-tls-openssl=yes, the following |
| 7 | compiler errors are reported: |
| 8 | |
| 9 | ``` |
| 10 | | ../../git/src/tcp.c:3765:1: error: no previous declaration for 'relpTcpGetRtryDirection_gtls' [-Werror=missing-declarations] |
| 11 | | 3765 | relpTcpGetRtryDirection_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
| 12 | | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 13 | | ../../git/src/tcp.c:3583:1: error: 'relpTcpChkPeerName' defined but not used [-Werror=unused-function] |
| 14 | | 3583 | relpTcpChkPeerName(NOTLS_UNUSED relpTcp_t *const pThis, NOTLS_UNUSED void* cert) |
| 15 | | | ^~~~~~~~~~~~~~~~~~ |
| 16 | ``` |
| 17 | |
| 18 | Fix these by: |
| 19 | 1. Add static on the openssl path for relpTcpGetRtryDirection_gtls. |
| 20 | 2. Move the relpTcpChkPeerName forward declaration to another ifdef |
| 21 | leg. |
| 22 | 3. Wrap relpTcpChkPeerName in gnutls-based ifdef. |
| 23 | 4. Remove relpTcpChkPeerName_gtls from openssl path. |
| 24 | |
| 25 | Upstream-Status: Backport [https://github.com/rsyslog/librelp/pull/255] |
| 26 | Signed-off-by: Patrick Williams <patrick@stwcx.xyz> |
| 27 | --- |
| 28 | src/tcp.c | 11 ++++------- |
| 29 | 1 file changed, 4 insertions(+), 7 deletions(-) |
| 30 | |
| 31 | diff --git a/src/tcp.c b/src/tcp.c |
| 32 | index 7a75cc4..18cffda 100644 |
| 33 | --- a/src/tcp.c |
| 34 | +++ b/src/tcp.c |
| 35 | @@ -132,12 +132,12 @@ callOnErr(const relpTcp_t *__restrict__ const pThis, |
| 36 | static int LIBRELP_ATTR_NONNULL() relpTcpGetCN(char *const namebuf, const size_t lenNamebuf, const char *const szDN); |
| 37 | #ifdef HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION |
| 38 | static int relpTcpVerifyCertificateCallback(gnutls_session_t session); |
| 39 | +static int relpTcpChkPeerName(relpTcp_t *const pThis, void* cert); |
| 40 | #endif /* #ifdef HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION */ |
| 41 | #if defined(HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION) || defined(ENABLE_TLS_OPENSSL) |
| 42 | static void relpTcpChkOnePeerName(relpTcp_t *const pThis, char *peername, int *pbFoundPositiveMatch); |
| 43 | static int relpTcpAddToCertNamesBuffer(relpTcp_t *const pThis, char *const buf, |
| 44 | const size_t buflen, int *p_currIdx, const char *const certName); |
| 45 | -static int relpTcpChkPeerName(relpTcp_t *const pThis, void* cert); |
| 46 | #endif /* defined(HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION) || defined(ENABLE_TLS_OPENSSL) */ |
| 47 | |
| 48 | |
| 49 | @@ -2820,11 +2820,6 @@ relpTcpLstnInitTLS_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
| 50 | { |
| 51 | return RELP_RET_ERR_INTERNAL; |
| 52 | } |
| 53 | -static int |
| 54 | -relpTcpChkPeerName_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis, LIBRELP_ATTR_UNUSED void *vcert) |
| 55 | -{ |
| 56 | - return RELP_RET_ERR_INTERNAL; |
| 57 | -} |
| 58 | #endif /* defined(ENABLE_TLS)*/ |
| 59 | |
| 60 | |
| 61 | @@ -3579,6 +3574,7 @@ finalize_it: |
| 62 | |
| 63 | } |
| 64 | |
| 65 | +#ifdef HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION |
| 66 | static int |
| 67 | relpTcpChkPeerName(NOTLS_UNUSED relpTcp_t *const pThis, NOTLS_UNUSED void* cert) |
| 68 | { |
| 69 | @@ -3592,6 +3588,7 @@ relpTcpChkPeerName(NOTLS_UNUSED relpTcp_t *const pThis, NOTLS_UNUSED void* cert) |
| 70 | #endif /* #ifdef WITH_TLS*/ |
| 71 | LEAVE_RELPFUNC; |
| 72 | } |
| 73 | +#endif |
| 74 | |
| 75 | static relpRetVal LIBRELP_ATTR_NONNULL() |
| 76 | relpTcpAcceptConnReqInitTLS(NOTLS_UNUSED relpTcp_t *const pThis, NOTLS_UNUSED relpSrv_t *const pSrv) |
| 77 | @@ -3761,7 +3758,7 @@ relpTcpGetRtryDirection_gtls(relpTcp_t *const pThis) |
| 78 | return gnutls_record_get_direction(pThis->session); |
| 79 | } |
| 80 | #else /* #ifdef ENABLE_TLS */ |
| 81 | -relpRetVal LIBRELP_ATTR_NONNULL() |
| 82 | +static relpRetVal LIBRELP_ATTR_NONNULL() |
| 83 | relpTcpGetRtryDirection_gtls(LIBRELP_ATTR_UNUSED relpTcp_t *const pThis) |
| 84 | { |
| 85 | return RELP_RET_ERR_INTERNAL; |
| 86 | -- |
| 87 | 2.41.0 |
| 88 | |