network: throw EnvoyException on address parse error#968
Merged
mattklein123 merged 4 commits intoenvoyproxy:masterfrom May 16, 2017
Merged
network: throw EnvoyException on address parse error#968mattklein123 merged 4 commits intoenvoyproxy:masterfrom
mattklein123 merged 4 commits intoenvoyproxy:masterfrom
Conversation
Contributor
Author
|
@ccaraman for review. |
source/common/network/utility.cc
Outdated
|
|
||
| Address::InstanceConstSharedPtr | ||
| Utility::parseInternetAddressAndPort(const std::string& ip_address) { | ||
| std::string error_msg(fmt::format("malformed IP address: {}", ip_address)); |
Member
There was a problem hiding this comment.
It would be best to not create this string when most times we will not need it. One solution is to move to a private helper function called throwOnMalformedIp(...) or something like that.
source/common/network/cidr_range.cc
Outdated
| if (parts.size() == 2) { | ||
| InstanceConstSharedPtr ptr = parseInternetAddress(parts[0]); | ||
| InstanceConstSharedPtr ptr = Utility::parseInternetAddress(parts[0]); | ||
| if (ptr != nullptr && ptr->type() == Type::Ip) { |
Member
There was a problem hiding this comment.
null check here is no longer needed
source/common/network/utility.cc
Outdated
| Address::InstanceConstSharedPtr | ||
| Utility::parseInternetAddressAndPort(const std::string& ip_address) { | ||
| if (ip_address.empty()) { | ||
| Utility::throwWithMalformedIp(ip_address); |
Member
There was a problem hiding this comment.
nit: don't need to specify Utility:: on these calls since already inside the class and static.
htuch
reviewed
May 16, 2017
source/common/network/utility.cc
Outdated
| sa6.sin6_port = 0; | ||
| return std::make_shared<Address::Ipv6Instance>(sa6); | ||
| } | ||
| throw EnvoyException(fmt::format("malformed IP address: {}", ip_address)); |
source/common/network/utility.h
Outdated
|
|
||
| /* | ||
| * Parse an internet host address (IPv4 or IPv6) AND port, and create an Instance from it. | ||
| * Throw an exception if unable to parse the address. |
Member
There was a problem hiding this comment.
You could also use an @throws Doxygen annotation, but this isn't common in the code base.
htuch
approved these changes
May 16, 2017
mattklein123
approved these changes
May 16, 2017
rshriram
pushed a commit
to rshriram/envoy
that referenced
this pull request
Oct 30, 2018
Automatic merge from submit-queue. [DO NOT MERGE] Auto PR to update dependencies of proxy This PR will be merged automatically once checks are successful. ```release-note none ```
jpsim
pushed a commit
that referenced
this pull request
Nov 28, 2022
Signed-off-by: Mike Schore <mike.schore@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
jpsim
pushed a commit
that referenced
this pull request
Nov 29, 2022
Signed-off-by: Mike Schore <mike.schore@gmail.com> Signed-off-by: JP Simard <jp@jpsim.com>
mathetake
pushed a commit
that referenced
this pull request
Mar 3, 2026
**Description** Simplify netlify CSP settings to use wildcards to ensure we do not have bugs for trusted domains. **Related Issues/PRs (if applicable)** n/a **Special notes for reviewers (if applicable)** n/a --------- Signed-off-by: Erica Hughberg <erica.sundberg.90@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously when an IP address could not be parsed, a nullptr was returned. However, this causes a segfault for config files with error(s) in the address field(s). This PR changes the address parsing logic to throw an exception instead.
This PR also moves IP address parsing functions from Network::Address to Network::Utility.
Fixes #952