@@ -22691,6 +22691,13 @@ static int test_wolfSSL_OCSP_parse_url(void)
2269122691 CK_OPU_FAIL("http/""/localhost");
2269222692 CK_OPU_FAIL("http:/localhost");
2269322693 CK_OPU_FAIL("https://localhost/path:1234");
22694+ /* CR/LF anywhere in the URL, paired or bare. */
22695+ CK_OPU_FAIL("http://localhost/\r\nX-Injected: yes");
22696+ CK_OPU_FAIL("http://localhost\r\n:1234/");
22697+ CK_OPU_FAIL("http://localhost/\nX-Injected: yes");
22698+ CK_OPU_FAIL("http://localhost/\rX-Injected: yes");
22699+ CK_OPU_FAIL("http://localhost\n:1234/");
22700+ CK_OPU_FAIL("http://localhost:12\r\n34/");
2269422701
2269522702#undef CK_OPU_OK
2269622703#undef CK_OPU_FAIL
@@ -23035,6 +23042,28 @@ static int test_wolfSSL_OCSP_REQ_CTX(void)
2303523042 ExpectNotNull(OCSP_request_add0_id(req, cid));
2303623043 ExpectIntEQ(OCSP_request_add1_nonce(req, NULL, -1), 1);
2303723044
23045+ ExpectNull(OCSP_sendreq_new(bio1, "/\r\nX-Injected: yes", NULL, -1));
23046+ ExpectNull(OCSP_sendreq_new(bio1, "/\nX-Injected: yes", NULL, -1));
23047+
23048+ /* Reject CR/LF and obs-fold, on a context that is thrown away so that the
23049+ * request assembled below stays clean. */
23050+ ExpectNotNull(ctx = OCSP_sendreq_new(bio1, "/", NULL, -1));
23051+ ExpectIntEQ(OCSP_REQ_CTX_http(ctx, "POST", "/\r\nX-Injected: yes"), 0);
23052+ ExpectIntEQ(OCSP_REQ_CTX_http(ctx, "POST\r\nX-Injected: yes", "/"), 0);
23053+ ExpectIntEQ(OCSP_REQ_CTX_add1_header(ctx, "X-Injected\r\nHost", "h"), 0);
23054+ ExpectIntEQ(OCSP_REQ_CTX_add1_header(ctx, "Host", "h\r\nX-Injected: yes"),
23055+ 0);
23056+ ExpectIntEQ(OCSP_REQ_CTX_http(ctx, "POST", "/\nX-Injected: yes"), 0);
23057+ ExpectIntEQ(OCSP_REQ_CTX_http(ctx, "POST", "/\rX-Injected: yes"), 0);
23058+ ExpectIntEQ(OCSP_REQ_CTX_add1_header(ctx, "Host", "h\nX-Injected: yes"), 0);
23059+ ExpectIntEQ(OCSP_REQ_CTX_add1_header(ctx, "Host", "h\rX-Injected: yes"), 0);
23060+ ExpectIntEQ(OCSP_REQ_CTX_add1_header(ctx, " Host", "h"), 0);
23061+ ExpectIntEQ(OCSP_REQ_CTX_add1_header(ctx, "\tHost", "h"), 0);
23062+ /* A NULL value is allowed and emits just the name. */
23063+ ExpectIntEQ(OCSP_REQ_CTX_add1_header(ctx, "X-No-Value", NULL), 1);
23064+ OCSP_REQ_CTX_free(ctx);
23065+ ctx = NULL;
23066+
2303823067 ExpectNotNull(ctx = OCSP_sendreq_new(bio1, "/", NULL, -1));
2303923068 ExpectIntEQ(OCSP_REQ_CTX_add1_header(ctx, "Host", "127.0.0.1"), 1);
2304023069 ExpectIntEQ(OCSP_REQ_CTX_set1_req(ctx, req), 1);
0 commit comments