aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-03-28 07:48:18 -0400
committerNick Mathewson <nickm@torproject.org>2018-03-28 07:48:18 -0400
commitd4bf1f6c8eb08c39def69c839515afe475bf0a6b (patch)
treef35bc9f3fd3336d82133b41352717870cc405d60
parentb504c854d34a938943f68c3036840f10a84fcea4 (diff)
downloadtor-d4bf1f6c8eb08c39def69c839515afe475bf0a6b.tar.gz
tor-d4bf1f6c8eb08c39def69c839515afe475bf0a6b.zip
Add a paranoia check in string_is_valid_nonrfc_hostname()
The earlier checks in this function should ensure that components is always nonempty. But in case somebody messes with them in the future, let's add an extra check to make sure we aren't crashing.
-rw-r--r--src/common/util.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 90aaf0ebeb..a68fd30d09 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1125,6 +1125,9 @@ string_is_valid_nonrfc_hostname(const char *string)
smartlist_split_string(components,string,".",0,0);
+ if (BUG(smartlist_len(components) == 0))
+ return 0; // LCOV_EXCL_LINE should be impossible given the earlier checks.
+
/* Allow a single terminating '.' used rarely to indicate domains
* are FQDNs rather than relative. */
last_label = (char *)smartlist_get(components,