Module: kamailio
Branch: master
Commit: cdf8cb6444f3b3f9aeb76053edc05bf595d4a583
URL:
https://github.com/kamailio/kamailio/commit/cdf8cb6444f3b3f9aeb76053edc05bf…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-04-05T07:54:15+02:00
dispatcher: check valid values for ds_dns_mode
---
Modified: src/modules/dispatcher/dispatch.c
Modified: src/modules/dispatcher/dispatch.h
Modified: src/modules/dispatcher/dispatcher.c
---
Diff:
https://github.com/kamailio/kamailio/commit/cdf8cb6444f3b3f9aeb76053edc05bf…
Patch:
https://github.com/kamailio/kamailio/commit/cdf8cb6444f3b3f9aeb76053edc05bf…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index 0ca8839c89..d59eebe23e 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -82,10 +82,6 @@
#define DS_HN_SIZE 256
-#define DS_DNS_MODE_INIT 0
-#define DS_DNS_MODE_ALWAYS 1
-#define DS_DNS_MODE_CACHE 2
-
/* increment call load */
#define DS_LOAD_INC(dgrp, didx) do { \
lock_get(&(dgrp)->lock); \
@@ -490,7 +486,7 @@ ds_dest_t *pack_dest(str iuri, int flags, int priority, str *attrs,
int dload)
/* Do a DNS-Lookup for the Host-Name, if not disabled via dst flags */
if(dp->flags & DS_NODNSARES_DST) {
dp->irmode |= DS_IRMODE_NOIPADDR;
- } else if (ds_dns_mode==DS_DNS_MODE_INIT || ds_dns_mode==DS_DNS_MODE_CACHE) {
+ } else if (ds_dns_mode==DS_DNS_MODE_INIT || ds_dns_mode==DS_DNS_MODE_TIMER) {
he = resolvehost(hn);
if(he == 0) {
LM_ERR("could not resolve %.*s (missing no-probing flag?!?)\n",
diff --git a/src/modules/dispatcher/dispatch.h b/src/modules/dispatcher/dispatch.h
index e360e67592..36e01e96ef 100644
--- a/src/modules/dispatcher/dispatch.h
+++ b/src/modules/dispatcher/dispatch.h
@@ -73,8 +73,12 @@
#define DS_XAVP_CTX_SKIP_CNT 1
#define DS_IRMODE_NOIPADDR 1
-/* clang-format on */
+#define DS_DNS_MODE_INIT 0
+#define DS_DNS_MODE_ALWAYS 1
+#define DS_DNS_MODE_TIMER 2
+
+/* clang-format on */
typedef struct ds_rctx {
int flags;
int code;
diff --git a/src/modules/dispatcher/dispatcher.c b/src/modules/dispatcher/dispatcher.c
index 42b1a41aa8..6317334fba 100644
--- a/src/modules/dispatcher/dispatcher.c
+++ b/src/modules/dispatcher/dispatcher.c
@@ -327,6 +327,12 @@ static int mod_init(void)
param_hooks_t phooks;
param_t *pit = NULL;
+ if(ds_dns_mode!=DS_DNS_MODE_INIT && ds_dns_mode!=DS_DNS_MODE_ALWAYS
+ && ds_dns_mode!=DS_DNS_MODE_TIMER) {
+ LM_ERR("invalid dns mode %d\n", ds_dns_mode);
+ return -1;
+ }
+
if(ds_ping_active_init() < 0) {
return -1;
}