11/* clu_ocsp.c
22 *
3- * Copyright (C) 2006-2025 wolfSSL Inc.
3+ * Copyright (C) 2006-2026 wolfSSL Inc.
44 *
55 * This file is part of wolfSSL.
66 *
@@ -511,10 +511,11 @@ static byte respBuffer[16384];
511511#ifndef _WIN32
512512 #include <signal.h>
513513 #include <errno.h>
514+ static volatile sig_atomic_t shutdownRequested = 0 ;
515+ #else
516+ static volatile int shutdownRequested = 0 ;
514517#endif
515518
516- static volatile sig_atomic_t shutdownRequested = 0 ;
517-
518519#ifndef _WIN32
519520/* Signal handler for SIGINT and SIGTERM - sets shutdown flag */
520521static void ocspSignalHandler (int sig )
@@ -752,27 +753,18 @@ static int ocspResponder(OcspResponderConfig* config)
752753 if (indexEntries != NULL ) {
753754 IndexEntry * entry ;
754755 for (entry = indexEntries ; entry != NULL ; entry = entry -> next ) {
755- byte serial [ 64 ] ;
756+ byte * serial = NULL ;
756757 word32 serialLen = 0 ;
757758 enum Ocsp_Cert_Status status ;
758759 time_t revTime = 0 ;
759- word32 i ;
760- char * p = entry -> serial ;
761760
762761 /* Convert hex string to bytes */
763- serialLen = (word32 )XSTRLEN (entry -> serial ) / 2 ;
764- if (serialLen == 0 || serialLen > sizeof (serial )) {
762+ if (wolfCLU_hexToBin (entry -> serial , & serial , & serialLen ,
763+ NULL , NULL , NULL , NULL , NULL , NULL ,
764+ NULL , NULL , NULL ) != WOLFCLU_SUCCESS ) {
765765 continue ;
766766 }
767767
768- for (i = 0 ; i < serialLen ; i ++ ) {
769- int high = (p [i * 2 ] >= 'A' ) ? (p [i * 2 ] - 'A' + 10 ) :
770- (p [i * 2 ] >= 'a' ) ? (p [i * 2 ] - 'a' + 10 ) : (p [i * 2 ] - '0' );
771- int low = (p [i * 2 + 1 ] >= 'A' ) ? (p [i * 2 + 1 ] - 'A' + 10 ) :
772- (p [i * 2 + 1 ] >= 'a' ) ? (p [i * 2 + 1 ] - 'a' + 10 ) : (p [i * 2 + 1 ] - '0' );
773- serial [i ] = (byte )((high << 4 ) | low );
774- }
775-
776768 /* Determine status */
777769 if (entry -> status == 'V' ) {
778770 status = CERT_GOOD ;
@@ -790,6 +782,7 @@ static int ocspResponder(OcspResponderConfig* config)
790782 serial , serialLen , status , revTime ,
791783 CRL_REASON_UNSPECIFIED ,
792784 (status == CERT_GOOD ) ? 86400 : 0 );
785+ wolfCLU_freeBins (serial , NULL , NULL , NULL , NULL );
793786 }
794787 }
795788
@@ -868,6 +861,9 @@ static int ocspResponder(OcspResponderConfig* config)
868861 if (transportSendResponse (clientfd , transportType , respBuffer , (int )respSz ) != 0 )
869862 goto continue_loop ;
870863
864+ /* Only count successfully processed requests toward the -nrequest
865+ * limit. Failed reads/sends jump to continue_loop above, so a
866+ * misbehaving client cannot exhaust the budget. */
871867 requestsProcessed ++ ;
872868
873869 /* Check if we've hit the request limit */
0 commit comments