Skip to content

Commit

Permalink
dispatcher: check valid values for ds_dns_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Apr 5, 2022
1 parent 1b5b0aa commit cdf8cb6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/modules/dispatcher/dispatch.c
Expand Up @@ -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); \
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion src/modules/dispatcher/dispatch.h
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/modules/dispatcher/dispatcher.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit cdf8cb6

Please sign in to comment.