Skip to content

Commit

Permalink
fuzz: use nanoseconds for SystemTime in RequestInfo. (envoyproxy#4255)
Browse files Browse the repository at this point in the history
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 <htuch@google.com>
  • Loading branch information
htuch committed Aug 27, 2018
1 parent ba6ba98 commit 35103b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
headers_to_add { header { key: " " value: "%START_TIME(�)%" } } request_info { start_time: 72059116831228591 }
8 changes: 7 additions & 1 deletion test/fuzz/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ inline test::fuzz::Headers toHeaders(const Http::HeaderMap& headers) {
inline TestRequestInfo fromRequestInfo(const test::fuzz::RequestInfo& request_info) {
TestRequestInfo test_request_info;
test_request_info.metadata_ = request_info.dynamic_metadata();
test_request_info.start_time_ = SystemTime(std::chrono::microseconds(request_info.start_time()));
#ifdef __APPLE__
// Clocks don't track at nanosecond on OS X.
test_request_info.start_time_ =
SystemTime(std::chrono::microseconds(request_info.start_time() / 1000));
#else
test_request_info.start_time_ = SystemTime(std::chrono::nanoseconds(request_info.start_time()));
#endif
if (request_info.has_response_code()) {
test_request_info.response_code_ = request_info.response_code().value();
}
Expand Down

0 comments on commit 35103b3

Please sign in to comment.