Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ci/asan_leak_suppression/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ leak:RegressionTest_PARENTSELECTION
leak:ParentConfig::reconfigure
leak:RegressionTest_SDK_API_TSHttpConnectIntercept
leak:RegressionTest_SDK_API_TSHttpConnectServerIntercept
leak:make_log_host
leak:ReRegressionSM::clone
leak:RegressionTest_ram_cache
leak:RegressionTest_HttpTransact_is_request_valid
Expand All @@ -11,9 +10,7 @@ leak:MakeTextLogFormat
leak:RegressionTest_HttpTransact_handle_trace_and_options_requests
leak:CRYPTO_malloc
leak:RegressionTest_SDK_API_TSMgmtGet
leak:RegressionTest_Cache_vol
leak:RegressionTest_SDK_API_TSCache
leak:RegressionTest_Hdrs
leak:RegressionTest_SDK_API_TSPortDescriptor
leak:RegressionTest_HostDBProcessor
leak:RegressionTest_DNS
Expand Down
12 changes: 3 additions & 9 deletions ci/asan_leak_suppression/unit_tests.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# leaks in test_X509HostnameValidator
leak:libcrypto.so.1.1
# for OpenSSL 1.0.2:
leak:CRYPTO_malloc
leak:CRYPTO_realloc
leak:ConsCell
# PR#10295
leak:pcre_jit_stack_alloc
# PR#10541
# marshal_hdr in test_http_hdr_print_and_copy_aux is intentionally
# not destroyed because it holds a reference to a stack-allocated
# TestRefCountObj whose free() override calls exit(1).
leak:test_http_hdr_print_and_copy_aux
54 changes: 26 additions & 28 deletions src/proxy/hdrs/unit_tests/test_Hdrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ test_http_hdr_copy_over_aux(int testnum, const char *request, const char *respon
HTTPHdr copy1;
HTTPHdr copy2;

ts::PostScript cleanup([&]() -> void {
req_hdr.destroy();
resp_hdr.destroy();
copy1.destroy();
copy2.destroy();
});

HTTPParser parser;
const char *start;
const char *end;
Expand Down Expand Up @@ -236,48 +243,36 @@ test_http_hdr_copy_over_aux(int testnum, const char *request, const char *respon
copy1.create(HTTPType::REQUEST);
copy1.copy(&req_hdr);
comp_str = comp_http_hdr(&req_hdr, &copy1);
if (comp_str) {
goto done;
}

copy2.create(HTTPType::RESPONSE);
copy2.copy(&resp_hdr);
comp_str = comp_http_hdr(&resp_hdr, &copy2);
if (comp_str) {
goto done;
if (!comp_str) {
copy2.create(HTTPType::RESPONSE);
copy2.copy(&resp_hdr);
comp_str = comp_http_hdr(&resp_hdr, &copy2);
}

// The APIs for copying headers uses memcpy() which can be unsafe for
// overlapping memory areas. It's unclear to me why these tests were
// created in the first place honestly, since nothing else does this.

/*** (4) Gender bending copying ***/
copy1.copy(&resp_hdr);
comp_str = comp_http_hdr(&resp_hdr, &copy1);
if (comp_str) {
goto done;
if (!comp_str) {
copy1.copy(&resp_hdr);
comp_str = comp_http_hdr(&resp_hdr, &copy1);
}

copy2.copy(&req_hdr);
comp_str = comp_http_hdr(&req_hdr, &copy2);
if (comp_str) {
goto done;
if (!comp_str) {
copy2.copy(&req_hdr);
comp_str = comp_http_hdr(&req_hdr, &copy2);
}

done:
req_hdr.destroy();
resp_hdr.destroy();
copy1.destroy();
copy2.destroy();

if (comp_str) {
printf("FAILED: (test #%d) copy & compare: %s\n", testnum, comp_str);
printf("REQ:\n[%.*s]\n", static_cast<int>(strlen(request)), request);
printf("RESP :\n[%.*s]\n", static_cast<int>(strlen(response)), response);
return (0);
} else {
return (1);
}

return (1);
}

int
Expand Down Expand Up @@ -379,10 +374,16 @@ test_http_hdr_print_and_copy_aux(int testnum, const char *request, const char *r
{
ParseResult err;
HTTPHdr hdr;
HTTPHdr new_hdr;
HTTPParser parser;
const char *start;
const char *end;

ts::PostScript cleanup([&]() -> void {
hdr.destroy();
new_hdr.destroy();
});

char prt_buf[2048];
int prt_bufsize = sizeof(prt_buf);
int prt_bufindex, prt_dumpoffset, prt_ret;
Expand Down Expand Up @@ -416,7 +417,7 @@ test_http_hdr_print_and_copy_aux(int testnum, const char *request, const char *r
}

/*** (2) copy the request header ***/
HTTPHdr new_hdr, marshal_hdr;
HTTPHdr marshal_hdr;
TestRefCountObj ref;

// Pretend to pin this object with a refcount.
Expand Down Expand Up @@ -524,9 +525,6 @@ test_http_hdr_print_and_copy_aux(int testnum, const char *request, const char *r
return (0);
}

hdr.destroy();
new_hdr.destroy();

if (test_http_hdr_copy_over_aux(testnum, request, response) == 0) {
return 0;
}
Expand Down
Loading