]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Bulletproof conn_get_outbound_address() a little.
authorNick Mathewson <nickm@torproject.org>
Fri, 27 Jan 2017 13:12:14 +0000 (08:12 -0500)
committerNick Mathewson <nickm@torproject.org>
Fri, 27 Jan 2017 13:12:14 +0000 (08:12 -0500)
src/or/connection.c

index 4421534b7f28e3018872cf7ea0f75851661c399f..188276026f510058f1e6cf8de3c9b121b85ecb16 100644 (file)
@@ -1902,10 +1902,18 @@ conn_get_outbound_address(sa_family_t family,
 {
   const tor_addr_t *ext_addr = NULL;
 
-  int fam_index=0;
-  if (family==AF_INET6) {
-    fam_index=1;
+  int fam_index;
+  switch (family) {
+    case AF_INET:
+      fam_index = 0;
+      break;
+    case AF_INET6:
+      fam_index = 1;
+      break;
+    default:
+      return NULL;
   }
+
   // If an exit connection, use the exit address (if present)
   if (conn_type == CONN_TYPE_EXIT) {
     if (!tor_addr_is_null(