[sr-dev] git:5.1:191d970e: core: better protection against invalid name lookup in DNS caching support

Henning Westerholt hw at kamailio.org
Sun Jun 17 17:25:56 CEST 2018


Module: kamailio
Branch: 5.1
Commit: 191d970eb1815109c6c6d273da3481afc856f396
URL: https://github.com/kamailio/kamailio/commit/191d970eb1815109c6c6d273da3481afc856f396

Author: Henning Westerholt <hw at kamailio.org>
Committer: Henning Westerholt <hw at kamailio.org>
Date: 2018-06-17T17:25:44+02:00

core: better protection against invalid name lookup in DNS caching support

(cherry picked from commit 74847c386f627ba89a0cb282e85d653388d45e24)

---

Modified: src/core/dns_cache.c

---

Diff:  https://github.com/kamailio/kamailio/commit/191d970eb1815109c6c6d273da3481afc856f396.diff
Patch: https://github.com/kamailio/kamailio/commit/191d970eb1815109c6c6d273da3481afc856f396.patch

---

diff --git a/src/core/dns_cache.c b/src/core/dns_cache.c
index 43ceb93ff6..ab91a2077a 100644
--- a/src/core/dns_cache.c
+++ b/src/core/dns_cache.c
@@ -536,6 +536,13 @@ inline static struct dns_hash_entry* _dns_hash_find(str* name, int type,
 	ret=0;
 	now=get_ticks_raw();
 	*err=0;
+
+	/* just in case that e.g. the VIA parser get confused */
+	if(unlikely(!name->s || name->len <= 0)) {
+		LM_ERR("invalid name, no cache lookup possible\n");
+		*err=-1;
+		return 0;
+	}
 again:
 	*h=dns_hash_no(name->s, name->len, type);
 #ifdef DNS_CACHE_DEBUG




More information about the sr-dev mailing list