Skip to content

Commit cdeeb04

Browse files
committed
Implement copilot suggestions
1 parent 07fce87 commit cdeeb04

5 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/ocsp/clu_ocsp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,10 @@ static int ocspResponder(OcspResponderConfig* config)
788788
goto cleanup;
789789
}
790790

791+
#ifndef _WIN32
791792
/* Setup signal handlers for graceful shutdown */
792793
setupSignalHandlers();
794+
#endif
793795

794796
WOLFCLU_LOG(WOLFCLU_L0, "OCSP responder%s listening on port %d",
795797
(transportType == TRANSPORT_SCGI) ? " (SCGI mode)" : "", config->port);
@@ -865,10 +867,6 @@ static int ocspResponder(OcspResponderConfig* config)
865867

866868
wolfCLU_ServerClose(clientfd);
867869
clientfd = INVALID_SOCKET;
868-
869-
if (config->nrequest > 0 && requestsProcessed >= config->nrequest) {
870-
break;
871-
}
872870
}
873871

874872
ret = WOLFCLU_SUCCESS;

src/tools/clu_http.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,11 @@ int wolfCLU_HttpServerRecv(SOCKET_T clientfd, byte* buffer, int bufferSz)
281281
cl = XSTRSTR((char*)buffer, "Content-Length:");
282282
if (cl == NULL)
283283
cl = XSTRSTR((char*)buffer, "content-length:");
284-
if (cl != NULL)
284+
if (cl != NULL) {
285285
contentLen = XATOI(cl + 15);
286+
if (contentLen < 0)
287+
contentLen = 0;
288+
}
286289
}
287290
}
288291
/* Check if we have the full body */
@@ -403,6 +406,9 @@ int wolfCLU_HttpServerParseRequest(const byte* httpReq, int httpReqSz,
403406
}
404407
if (contentLen) {
405408
*bodySz = XATOI(contentLen + 15);
409+
if (*bodySz < 0) {
410+
return -1;
411+
}
406412
}
407413

408414
/* Find body (after \r\n\r\n) */

src/tools/clu_pem_der.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ static int loadFileToDer(const char* filename, byte** der, word32* derSz, int pe
8080
XMEMCPY(*der, pDer->buffer, pDer->length);
8181
*derSz = pDer->length;
8282
}
83-
wc_FreeDer(&pDer);
8483
}
84+
wc_FreeDer(&pDer);
8585
XFREE(buf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
8686
return (*der != NULL) ? 0 : -1;
8787
}

src/tools/clu_scgi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ static int parseNetstringLength(SOCKET_T sockfd, int* length)
9696
if (lenBuf[i] == ':') {
9797
lenBuf[i] = '\0';
9898
*length = XATOI(lenBuf);
99+
if (*length < 0) {
100+
return -1;
101+
}
99102
return 0;
100103
}
101104
i++;

tests/ocsp-scgi/scgi_params

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ scgi_param CONTENT_TYPE $content_type;
55
scgi_param CONTENT_LENGTH $content_length;
66

77
scgi_param SCRIPT_NAME $fastcgi_script_name;
8-
scgi_param REQUEST_URI $request_uri;
98
scgi_param DOCUMENT_URI $document_uri;
109
scgi_param DOCUMENT_ROOT $document_root;
1110
scgi_param SERVER_PROTOCOL $server_protocol;

0 commit comments

Comments
 (0)