Skip to content

Commit

Permalink
additional safety for tls_config()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Jul 22, 2024
1 parent 58531b3 commit b251026
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ SEXP rnng_tls_config(SEXP client, SEXP server, SEXP pass, SEXP auth) {
const char *crl, *file, *key, *pss;
SEXP xp;

if ((usefile = Rf_xlength(client)) > 0) {
file = NANO_STRING(client);
if (client != R_NilValue) {
file = CHAR(STRING_ELT(client, 0));
usefile = XLENGTH(client);
if (usefile > 1)
crl = NANO_STR_N(client, 1);
if ((xc = nng_tls_config_alloc(&cfg, NNG_TLS_MODE_CLIENT)))
Expand All @@ -311,9 +312,10 @@ SEXP rnng_tls_config(SEXP client, SEXP server, SEXP pass, SEXP auth) {
goto exitlevel2;
}

} else if ((usefile = Rf_xlength(server)) > 0) {
file = NANO_STRING(server);
pss = pass != R_NilValue ? NANO_STRING(pass) : NULL;
} else if (server != R_NilValue) {
file = CHAR(STRING_ELT(server, 0));
usefile = XLENGTH(server);
pss = pass != R_NilValue ? CHAR(STRING_ELT(pass, 0)) : NULL;
if (usefile > 1)
key = NANO_STR_N(server, 1);
if ((xc = nng_tls_config_alloc(&cfg, NNG_TLS_MODE_SERVER)))
Expand Down

0 comments on commit b251026

Please sign in to comment.