From d2dac8e4b8d90000811334695ff320e461c3f431 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Wed, 21 Oct 2020 13:30:51 -0700 Subject: [PATCH] Example Client OCSP Option Fix 1. Before checking to see if the must staple flag is on the 'W' option, check the length of myoptarg. --- examples/client/client.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/client/client.c b/examples/client/client.c index 8af3ec123..88795ac0d 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -1944,15 +1944,21 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args) case 'W' : #if defined(HAVE_CERTIFICATE_STATUS_REQUEST) \ || defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) + { + word32 myoptargSz; + statusRequest = atoi(myoptarg); if (statusRequest > OCSP_STAPLING_OPT_MAX) { Usage(); XEXIT_T(MY_EX_USAGE); } - if (myoptarg[XSTRLEN(myoptarg)-1] == 'M' || - myoptarg[XSTRLEN(myoptarg)-1] == 'm') { + + myoptargSz = (word32)XSTRLEN(myoptarg); + if (myoptargSz > 0 && + XTOUPPER(myoptarg[myoptargSz-1]) == 'M') { mustStaple = 1; } + } #endif break;