Module: kamailio
Branch: 5.0
Commit: 93539394b22a1c755821b09574b93d72d34d7689
URL:
https://github.com/kamailio/kamailio/commit/93539394b22a1c755821b09574b93d7…
Author: Henning Westerholt <hw(a)kamailio.org>
Committer: Henning Westerholt <hw(a)kamailio.org>
Date: 2018-06-17T17:25:58+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/93539394b22a1c755821b09574b93d7…
Patch:
https://github.com/kamailio/kamailio/commit/93539394b22a1c755821b09574b93d7…
---
diff --git a/src/core/dns_cache.c b/src/core/dns_cache.c
index 5d35c52dee..04f230b7cc 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