aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard Walters <rwalters@digitalstirling.com>2018-07-04 16:12:45 -0700
committerRichard Walters <rwalters@digitalstirling.com>2018-07-04 16:12:45 -0700
commit4603102722e1cc2abc3494c9446bc576d008e7fa (patch)
tree514456971b60e7f2f5aa427b630a9b6a4425818d /src
parent98a41c1c33cead6dcb6737d7e3038111814f672d (diff)
Fix bug in truncated host elements
For example, "[::1", where the square bracket at the end is missing. Handle truncated host element by checking the state we end up in after the entire string is parsed. Some states represent interal elements of a host name or address, and so if we're still in those states and run out of input characters, the input string was cut off early.
Diffstat (limited to 'src')
-rw-r--r--src/Uri.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Uri.cpp b/src/Uri.cpp
index 56889b7..dbc9ff6 100644
--- a/src/Uri.cpp
+++ b/src/Uri.cpp
@@ -741,6 +741,15 @@ namespace Uri {
} break;
}
}
+ if (
+ (hostParsingState != HostParsingState::FIRST_CHARACTER)
+ && (hostParsingState != HostParsingState::NOT_IP_LITERAL)
+ && (hostParsingState != HostParsingState::GARBAGE_CHECK)
+ && (hostParsingState != HostParsingState::PORT)
+ ) {
+ // truncated or ended early
+ return false;
+ }
if (hostIsRegName) {
host = NormalizeCaseInsensitiveString(host);
}