commit 60cd969: [Fix] Same fix for lua_tcp

Vsevolod Stakhov vsevolod at rspamd.com
Sun Sep 25 12:07:04 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-09-25 13:05:00 +0100
URL: https://github.com/rspamd/rspamd/commit/60cd96905a9eab257074634a18aae8c711d62293 (HEAD -> master)

[Fix] Same fix for lua_tcp

---
 src/lua/lua_tcp.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c
index 73b2c9ae2..05c9de7a2 100644
--- a/src/lua/lua_tcp.c
+++ b/src/lua/lua_tcp.c
@@ -1378,17 +1378,30 @@ lua_tcp_dns_handler (struct rdns_reply *reply, gpointer ud)
 		 * We set this flag as it means that we have already registered the watcher
 		 * when started DNS query
 		 */
-		cbd->flags |= LUA_TCP_FLAG_RESOLVED;
+		struct rdns_reply_entry *entry;
 
-		if (reply->entries->type == RDNS_REQUEST_A) {
-			cbd->addr = rspamd_inet_address_new (AF_INET,
-					&reply->entries->content.a.addr);
+		DL_FOREACH(reply->entries, entry) {
+			if (entry->type == RDNS_REQUEST_A) {
+				cbd->addr = rspamd_inet_address_new(AF_INET,
+						&entry->content.a.addr);
+				break;
+			}
+			else if (entry->type == RDNS_REQUEST_AAAA) {
+				cbd->addr = rspamd_inet_address_new(AF_INET6,
+						&entry->content.aaa.addr);
+				break;
+			}
 		}
-		else if (reply->entries->type == RDNS_REQUEST_AAAA) {
-			cbd->addr = rspamd_inet_address_new (AF_INET6,
-					&reply->entries->content.aaa.addr);
+
+		if (cbd->addr == NULL){
+			rn = rdns_request_get_name (reply->request, NULL);
+			lua_tcp_push_error (cbd, TRUE, "unable to resolve host: %s; no records with this name",
+					rn->name);
+			TCP_RELEASE (cbd);
+			return;
 		}
 
+		cbd->flags |= LUA_TCP_FLAG_RESOLVED;
 		rspamd_inet_address_set_port (cbd->addr, cbd->port);
 
 		if (!lua_tcp_make_connection (cbd)) {


More information about the Commits mailing list