Skip to content

Commit

Permalink
Fix bug with numeric domains/subdomains or ones beginning by a digit.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-vincent committed Feb 29, 2020
1 parent d485b75 commit 4bfe5a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libs/asiotap/src/stream_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ namespace asiotap

AddressType::from_string(result, ec);

if (ec)
if (ec ||
(result.find(".") == std::string::npos &&
result.find(":") == std::string::npos))
{
// Unable to parse the IP address: putting back characters.
putback(is, result);
Expand Down Expand Up @@ -242,7 +244,7 @@ namespace asiotap
const std::string& result = oss.str();

// Check if the label is too long, if the last character is not a regular character or if it contains only digits
if ((result.size() > HOSTNAME_LABEL_MAX_SIZE) || (!is_hostname_label_regular_character(result[result.size() - 1])) || (result.find_first_not_of("0123456789") == std::string::npos))
if ((result.size() > HOSTNAME_LABEL_MAX_SIZE) || (!is_hostname_label_regular_character(result[result.size() - 1])))
{
putback(is, result);
is.setstate(std::ios_base::failbit);
Expand Down

0 comments on commit 4bfe5a7

Please sign in to comment.