Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions src/proxy/hdrs/unit_tests/test_Huffmancode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ TEST_CASE("encode_test", "[proxy][huffman]")
int64_t encoded_len = huffman_encode(dst, i.expect_len, i.src, i.src_len);

REQUIRE(encoded_len == i.expect_len);
REQUIRE(memcmp(i.expect, dst, encoded_len) == 0);
REQUIRE(memcmp(i.expect, dst, static_cast<size_t>(i.expect_len)) == 0);

free(dst);
}
Expand Down Expand Up @@ -219,7 +219,7 @@ TEST_CASE("decode_known_vectors", "[proxy][huffman]")
int64_t len = huffman_decode(dst, sizeof(dst), i.expect, i.expect_len);

REQUIRE(len == i.src_len);
REQUIRE(memcmp(dst, i.src, len) == 0);
REQUIRE(memcmp(dst, i.src, static_cast<size_t>(i.src_len)) == 0);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/proxy/hdrs/unit_tests/test_XPACK.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TEST_CASE("XPACK_Integer", "[xpack]")

REQUIRE(len > 0);
REQUIRE(len == i.encoded_field_len);
REQUIRE(memcmp(buf, i.encoded_field, len) == 0);
REQUIRE(memcmp(buf, i.encoded_field, static_cast<size_t>(i.encoded_field_len)) == 0);
}
}

Expand Down Expand Up @@ -136,7 +136,7 @@ TEST_CASE("XPACK_String", "[xpack]")

REQUIRE(len > 0);
REQUIRE(len == string_test_case[i].encoded_field_len);
REQUIRE(memcmp(buf, string_test_case[i].encoded_field, len) == 0);
REQUIRE(memcmp(buf, string_test_case[i].encoded_field, static_cast<size_t>(string_test_case[i].encoded_field_len)) == 0);
}
}

Expand All @@ -151,7 +151,7 @@ TEST_CASE("XPACK_String", "[xpack]")

REQUIRE(len == i.encoded_field_len);
REQUIRE(actual_len == i.raw_string_len);
REQUIRE(memcmp(actual, i.raw_string, actual_len) == 0);
REQUIRE(memcmp(actual, i.raw_string, i.raw_string_len) == 0);
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/proxy/http2/unit_tests/test_HpackIndexingTable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ TEST_CASE("HPACK low level APIs", "[hpack]")

REQUIRE(len > 0);
REQUIRE(len == i.encoded_field_len);
REQUIRE(memcmp(buf, i.encoded_field, len) == 0);

REQUIRE(memcmp(buf, i.encoded_field, static_cast<size_t>(i.encoded_field_len)) == 0);
}
}

Expand Down Expand Up @@ -240,8 +241,10 @@ TEST_CASE("HPACK low level APIs", "[hpack]")

REQUIRE(len > 0);
REQUIRE(len == literal_test_case[i].encoded_field_len);

// coverity[overrun-buffer-arg] - len is validated positive above
REQUIRE(memcmp(buf, literal_test_case[i].encoded_field, len) == 0);
REQUIRE(memcmp(buf, literal_test_case[i].encoded_field, static_cast<size_t>(literal_test_case[i].encoded_field_len)) ==
0);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/proxy/logging/unit-tests/test_LogAccess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ TEST_CASE("LogAccess marshals response HTTP versions as compact strings", "[LogA
int len = LogAccess::unmarshal_http_version(&src, dest, sizeof(dest));

REQUIRE(len > 0);
CHECK(std::string(dest, len) == "HTTP/0.0");
const size_t version_len = static_cast<size_t>(len);

CHECK(std::string(dest, version_len) == "HTTP/0.0");
CHECK(src == marshalled + INK_MIN_ALIGN);
};

Expand Down
28 changes: 21 additions & 7 deletions src/traffic_logcat/unit-tests/test_LogEntryJson.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ TEST_CASE("v3 generic decode round-trip with IPv4, STRING, INT", "[logcat][v3]")
char out[256];
int n = log_entry_to_json(entry, seg.header(), out, sizeof(out));
REQUIRE(n > 0);
CHECK(std::string(out, n) == R"({"chi":"192.0.2.10","cqu":"GET /index.html","pssc":200})");
const size_t len = static_cast<size_t>(n);

CHECK(std::string(out, len) == R"({"chi":"192.0.2.10","cqu":"GET /index.html","pssc":200})");
}

TEST_CASE("v3 generic decode handles IPv6 and unspecified IP", "[logcat][v3]")
Expand All @@ -129,7 +131,9 @@ TEST_CASE("v3 generic decode handles IPv6 and unspecified IP", "[logcat][v3]")
char out[256];
int n = log_entry_to_json(entry, seg.header(), out, sizeof(out));
REQUIRE(n > 0);
return std::string(out, n);
const size_t len = static_cast<size_t>(n);

return std::string(out, len);
};

SECTION("IPv6")
Expand Down Expand Up @@ -181,7 +185,9 @@ TEST_CASE("v3 generic decode escapes JSON structural characters in strings", "[l
char out[256];
int n = log_entry_to_json(entry, seg.header(), out, sizeof(out));
REQUIRE(n > 0);
CHECK(std::string(out, n) == R"({"msg":"he\"llo\\x"})");
const size_t len = static_cast<size_t>(n);

CHECK(std::string(out, len) == R"({"msg":"he\"llo\\x"})");
}

TEST_CASE("v3 generic decode escapes control characters in strings", "[logcat][v3]")
Expand All @@ -205,7 +211,9 @@ TEST_CASE("v3 generic decode escapes control characters in strings", "[logcat][v
char out[256];
int n = log_entry_to_json(entry, seg.header(), out, sizeof(out));
REQUIRE(n > 0);
CHECK(std::string(out, n) == R"({"msg":"a\nb\tc\u0001d"})");
const size_t len = static_cast<size_t>(n);

CHECK(std::string(out, len) == R"({"msg":"a\nb\tc\u0001d"})");
}

TEST_CASE("v3 generic decode escapes JSON structural characters in symbol keys", "[logcat][v3]")
Expand All @@ -226,7 +234,9 @@ TEST_CASE("v3 generic decode escapes JSON structural characters in symbol keys",
char out[256];
int n = log_entry_to_json(entry, seg.header(), out, sizeof(out));
REQUIRE(n > 0);
CHECK(std::string(out, n) == R"({"a\"b\\c":7})");
const size_t len = static_cast<size_t>(n);

CHECK(std::string(out, len) == R"({"a\"b\\c":7})");
}

TEST_CASE("v3 generic decode rejects an unknown type code", "[logcat][v3]")
Expand Down Expand Up @@ -309,7 +319,9 @@ TEST_CASE("v3 generic decode reads a dINT field (16 bytes)", "[logcat][v3]")
char out[256];
int n = log_entry_to_json(entry, seg.header(), out, sizeof(out));
REQUIRE(n > 0);
CHECK(std::string(out, n) == R"({"pair":[1,1]})");
const size_t len = static_cast<size_t>(n);

CHECK(std::string(out, len) == R"({"pair":[1,1]})");
}

TEST_CASE("v3 generic decode rejects a truncated dINT field", "[logcat][v3]")
Expand Down Expand Up @@ -361,5 +373,7 @@ TEST_CASE("v3 generic decode emits raw values, never field semantics", "[logcat]
char out[256];
int n = log_entry_to_json(entry, seg.header(), out, sizeof(out));
REQUIRE(n > 0);
CHECK(std::string(out, n) == R"({"crc":2,"cqts":1700000000})");
const size_t len = static_cast<size_t>(n);

CHECK(std::string(out, len) == R"({"crc":2,"cqts":1700000000})");
}