]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Handle empty DNS reply without error as NOERROR
authorDaniel Winzen <daniel@danwin1210.de>
Tue, 24 Sep 2024 13:07:59 +0000 (15:07 +0200)
committerDaniel Winzen <daniel@danwin1210.de>
Thu, 24 Oct 2024 08:03:50 +0000 (10:03 +0200)
src/core/or/or.h
src/core/or/relay.c
src/feature/client/dnsserv.c
src/test/test_relaycell.c

index 088c45342b673936afcf2be13c81eb06d3262d89..536b2ecdb959609eefa66bf910cfdf3744432d9c 100644 (file)
@@ -301,6 +301,8 @@ struct curve25519_public_key_t;
 #define RESOLVED_TYPE_IPV6 6
 #define RESOLVED_TYPE_ERROR_TRANSIENT 0xF0
 #define RESOLVED_TYPE_ERROR 0xF1
+/* C Tor internal error code to handle empty dns reply */
+#define RESOLVED_TYPE_NOERROR 0x01F2
 
 /* Negative reasons are internal: we never send them in a DESTROY or TRUNCATE
  * call; they only go to the controller for tracking  */
index f7d200c18d5620585d103ad144b65e8abd10fd02..9e62538421b5c18f3c8bc8566339928f13462f9a 100644 (file)
@@ -1343,7 +1343,7 @@ connection_ap_handshake_socks_got_resolved_cell(entry_connection_t *conn,
   /* Now convert it to the ugly old interface */
   if (! addr_best) {
     connection_ap_handshake_socks_resolved(conn,
-                                     RESOLVED_TYPE_ERROR,0,NULL,-1,-1);
+                                     RESOLVED_TYPE_NOERROR,0,NULL,-1,-1);
     return;
   }
 
index f0bb0af100ae807fbdf73b5b3ff98a5e1c54ec4d..237a6ee3d3dd4a05ba0dcbd95cc8da334bdaad1b 100644 (file)
@@ -319,6 +319,7 @@ evdns_get_orig_address(const struct evdns_server_request *req,
     break;
   case RESOLVED_TYPE_ERROR:
   case RESOLVED_TYPE_ERROR_TRANSIENT:
+  case RESOLVED_TYPE_NOERROR:
      /* Addr doesn't matter, since we're not sending it back in the reply.*/
     return addr;
   default:
@@ -379,6 +380,8 @@ dnsserv_resolved(entry_connection_t *conn,
     tor_free(ans);
   } else if (answer_type == RESOLVED_TYPE_ERROR) {
     err = DNS_ERR_NOTEXIST;
+  } else if (answer_type == RESOLVED_TYPE_NOERROR) {
+    err = DNS_ERR_NONE;
   } else { /* answer_type == RESOLVED_TYPE_ERROR_TRANSIENT */
     err = DNS_ERR_SERVERFAILED;
   }
index 05e2b2e347a31266ef6d72573e2cce7f13ed6c12..6edc1030f900c2b6583e979ad13d0fa065c02baf 100644 (file)
@@ -988,7 +988,7 @@ test_relaycell_resolved(void *arg)
   tt_int_op(r, OP_EQ, 0);
   ASSERT_MARK_CALLED(END_STREAM_REASON_DONE|
                      END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
-  ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_ERROR, NULL, -1, -1);
+  ASSERT_RESOLVED_CALLED(RESOLVED_TYPE_NOERROR, NULL, -1, -1);
 
   /* If we wanted hostnames, we report nothing, since we only had IPs. */
   MOCK_RESET();