Skip to content

Commit 35103b3

Browse files
authored
fuzz: use nanoseconds for SystemTime in RequestInfo. (#4255)
Avoids integer overflow that was previously occurring due to time in micros being too large, allows exercise of nanosecond resolution formatters beyond all zero. Fixes oss-fuzz issue https://oss-fuzz.com/v2/testcase-detail/5630125928873984. Risk level: Low Testing: Corpus entry added. Signed-off-by: Harvey Tuch <[email protected]>
1 parent ba6ba98 commit 35103b3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
headers_to_add { header { key: " " value: "%START_TIME(�)%" } } request_info { start_time: 72059116831228591 }

test/fuzz/utility.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ inline test::fuzz::Headers toHeaders(const Http::HeaderMap& headers) {
3636
inline TestRequestInfo fromRequestInfo(const test::fuzz::RequestInfo& request_info) {
3737
TestRequestInfo test_request_info;
3838
test_request_info.metadata_ = request_info.dynamic_metadata();
39-
test_request_info.start_time_ = SystemTime(std::chrono::microseconds(request_info.start_time()));
39+
#ifdef __APPLE__
40+
// Clocks don't track at nanosecond on OS X.
41+
test_request_info.start_time_ =
42+
SystemTime(std::chrono::microseconds(request_info.start_time() / 1000));
43+
#else
44+
test_request_info.start_time_ = SystemTime(std::chrono::nanoseconds(request_info.start_time()));
45+
#endif
4046
if (request_info.has_response_code()) {
4147
test_request_info.response_code_ = request_info.response_code().value();
4248
}

0 commit comments

Comments
 (0)