Skip to content

Commit b251026

Browse files
committed
additional safety for tls_config()
1 parent 58531b3 commit b251026

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/tls.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,9 @@ SEXP rnng_tls_config(SEXP client, SEXP server, SEXP pass, SEXP auth) {
293293
const char *crl, *file, *key, *pss;
294294
SEXP xp;
295295

296-
if ((usefile = Rf_xlength(client)) > 0) {
297-
file = NANO_STRING(client);
296+
if (client != R_NilValue) {
297+
file = CHAR(STRING_ELT(client, 0));
298+
usefile = XLENGTH(client);
298299
if (usefile > 1)
299300
crl = NANO_STR_N(client, 1);
300301
if ((xc = nng_tls_config_alloc(&cfg, NNG_TLS_MODE_CLIENT)))
@@ -311,9 +312,10 @@ SEXP rnng_tls_config(SEXP client, SEXP server, SEXP pass, SEXP auth) {
311312
goto exitlevel2;
312313
}
313314

314-
} else if ((usefile = Rf_xlength(server)) > 0) {
315-
file = NANO_STRING(server);
316-
pss = pass != R_NilValue ? NANO_STRING(pass) : NULL;
315+
} else if (server != R_NilValue) {
316+
file = CHAR(STRING_ELT(server, 0));
317+
usefile = XLENGTH(server);
318+
pss = pass != R_NilValue ? CHAR(STRING_ELT(pass, 0)) : NULL;
317319
if (usefile > 1)
318320
key = NANO_STR_N(server, 1);
319321
if ((xc = nng_tls_config_alloc(&cfg, NNG_TLS_MODE_SERVER)))

0 commit comments

Comments
 (0)