diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-07-21 14:07:04 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-07-21 14:10:39 -0700 |
| commit | c0b93b441199619d27a1caf201a8c410f4246cf4 (patch) | |
| tree | fce74fe8c72712cc1b731c1dde6ced6d8459d1b6 /src/core | |
| parent | 8c5142a88594067e8c8ad6eedc4f82ffc15595cc (diff) | |
| download | nng-c0b93b441199619d27a1caf201a8c410f4246cf4.tar.gz nng-c0b93b441199619d27a1caf201a8c410f4246cf4.tar.bz2 nng-c0b93b441199619d27a1caf201a8c410f4246cf4.zip | |
fixes #1835 setting NNG_OPT_TLS_CONFIG on socket should hold reference
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/socket.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index ea51c06f..e501a2da 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -12,6 +12,7 @@ #include "core/pipe.h" #include "list.h" #include "nng/nng.h" +#include "nng/supplemental/tls/tls.h" #include "sockimpl.h" #include <stdio.h> @@ -337,6 +338,10 @@ static const nni_option sock_options[] = { static void nni_free_opt(nni_sockopt *opt) { + if ((strcmp(opt->name, NNG_OPT_TLS_CONFIG) == 0) && + (opt->sz == sizeof(nng_tls_config *))) { + nng_tls_config_free(*(nng_tls_config **) (opt->data)); + } nni_strfree(opt->name); nni_free(opt->data, opt->sz); NNI_FREE_STRUCT(opt); @@ -1045,9 +1050,13 @@ nni_sock_setopt( // TLS options may not be supported if TLS is not // compiled in. Supporting all these is deprecated. } else if (strcmp(name, NNG_OPT_TLS_CONFIG) == 0) { - if ((rv = nni_copyin_ptr(NULL, v, sz, t)) != 0) { + nng_tls_config *tc; + if ((rv = nni_copyin_ptr((void **) &tc, v, sz, t)) != 0) { return (rv); } + // place a hold on this configuration object + nng_tls_config_hold(tc); + } else if ((strcmp(name, NNG_OPT_TLS_SERVER_NAME) == 0) || (strcmp(name, NNG_OPT_TLS_CA_FILE) == 0) || (strcmp(name, NNG_OPT_TLS_CERT_KEY_FILE) == 0)) { |
