[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Don't leak on logic error in string_is_valid_nonrfc_hostname()



commit 4e3d144fb0940d8ee5a89427d471ea3656e8e122
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Apr 11 17:40:05 2019 -0400

    Don't leak on logic error in string_is_valid_nonrfc_hostname()
    
    This is CID 1437438.  No backport needed: this is unreachable, and
    guarded with a BUG() check.
---
 src/lib/net/address.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index 214d8aa3e..7dec4c8e2 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -2027,8 +2027,12 @@ 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.
+  if (BUG(smartlist_len(components) == 0)) {
+    // LCOV_EXCL_START should be impossible given the earlier checks.
+    smartlist_free(components);
+    return 0;
+    // LCOV_EXCL_STOP
+  }
 
   /* Allow a single terminating '.' used rarely to indicate domains
    * are FQDNs rather than relative. */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits