Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuzz: fixes oss-fuzz: 8363 #3905

Merged
merged 4 commits into from
Jul 25, 2018
Merged
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions source/common/protobuf/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ uint64_t fractionalPercentDenominatorToInt(const envoy::type::FractionalPercent&
// Issue: https://github.com/lyft/protoc-gen-validate/issues/85
#define PROTOBUF_PERCENT_TO_ROUNDED_INTEGER_OR_DEFAULT(message, field_name, max_value, \
default_value) \
((message).has_##field_name() && !std::isnan((message).field_name().value()) \
? ProtobufPercentHelper::convertPercent((message).field_name().value(), max_value) \
((message).has_##field_name() \
? !std::isnan((message).field_name().value()) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would flip the logic here to have the isnan case first.

? ProtobufPercentHelper::convertPercent((message).field_name().value(), max_value) \
: throw EnvoyException(fmt::format("Value not in the range of 0..100 range.")) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test? Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

: ProtobufPercentHelper::checkAndReturnDefault(default_value, max_value))

namespace Envoy {
Expand Down