[sr-dev] git:master:74847c38: core: better protection against invalid name lookup in DNS caching support

Henning Westerholt hw at kamailio.org
Sun Jun 17 17:14:37 CEST 2018


Module: kamailio
Branch: master
Commit: 74847c386f627ba89a0cb282e85d653388d45e24
URL: https://github.com/kamailio/kamailio/commit/74847c386f627ba89a0cb282e85d653388d45e24

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

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

---

Modified: src/core/dns_cache.c

---

Diff:  https://github.com/kamailio/kamailio/commit/74847c386f627ba89a0cb282e85d653388d45e24.diff
Patch: https://github.com/kamailio/kamailio/commit/74847c386f627ba89a0cb282e85d653388d45e24.patch

---

diff --git a/src/core/dns_cache.c b/src/core/dns_cache.c
index 554c7c9903..d9fc6a21cc 100644
--- a/src/core/dns_cache.c
+++ b/src/core/dns_cache.c
@@ -510,6 +510,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);
 	LM_DBG("(%.*s(%d), %d), h=%d\n", name->len, name->s, name->len, type, *h);




More information about the sr-dev mailing list