From 4bfe5a7be1a26b04c43fc4d9768cb5238bceee0c Mon Sep 17 00:00:00 2001 From: Sebastien Vincent Date: Sat, 29 Feb 2020 13:34:34 +0100 Subject: [PATCH] Fix bug with numeric domains/subdomains or ones beginning by a digit. --- libs/asiotap/src/stream_operations.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/asiotap/src/stream_operations.cpp b/libs/asiotap/src/stream_operations.cpp index 03a5b462..41a96eac 100644 --- a/libs/asiotap/src/stream_operations.cpp +++ b/libs/asiotap/src/stream_operations.cpp @@ -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); @@ -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);