Skip to content
Snippets Groups Projects
Commit d260293f authored by James Golovich's avatar James Golovich
Browse files

Make DNS callbacks return -1 on error, so invalid records are ignored

(bug #1137)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2311 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 22b56f13
Branches
Tags
No related merge requests found
...@@ -137,8 +137,10 @@ static int dns_parse_answer(void *context, ...@@ -137,8 +137,10 @@ static int dns_parse_answer(void *context,
if (ntohs(ans->class) == class && ntohs(ans->rtype) == type) { if (ntohs(ans->class) == class && ntohs(ans->rtype) == type) {
if (callback) { if (callback) {
if ((res = callback(context, answer, ntohs(ans->size), fullanswer)) < 0) if ((res = callback(context, answer, ntohs(ans->size), fullanswer)) < 0) {
ast_log(LOG_WARNING, "Failed to parse result\n"); ast_log(LOG_WARNING, "Failed to parse result\n");
return -1;
}
if (res > 0) if (res > 0)
return 1; return 1;
} }
......
...@@ -232,8 +232,10 @@ static int enum_callback(void *context, u_char *answer, int len, u_char *fullans ...@@ -232,8 +232,10 @@ static int enum_callback(void *context, u_char *answer, int len, u_char *fullans
{ {
struct enum_context *c = (struct enum_context *)context; struct enum_context *c = (struct enum_context *)context;
if (parse_naptr(c->dst, c->dstlen, c->tech, c->techlen, answer, len, c->naptrinput)) if (parse_naptr(c->dst, c->dstlen, c->tech, c->techlen, answer, len, c->naptrinput)) {
ast_log(LOG_WARNING, "Failed to parse naptr :(\n"); ast_log(LOG_WARNING, "Failed to parse naptr :(\n");
return -1;
}
if (strlen(c->dst)) if (strlen(c->dst))
return 1; return 1;
......
...@@ -79,8 +79,10 @@ static int srv_callback(void *context, u_char *answer, int len, u_char *fullansw ...@@ -79,8 +79,10 @@ static int srv_callback(void *context, u_char *answer, int len, u_char *fullansw
{ {
struct srv_context *c = (struct srv_context *)context; struct srv_context *c = (struct srv_context *)context;
if (parse_srv(c->host, c->hostlen, c->port, answer, len, fullanswer)) if (parse_srv(c->host, c->hostlen, c->port, answer, len, fullanswer)) {
ast_log(LOG_WARNING, "Failed to parse srv\n"); ast_log(LOG_WARNING, "Failed to parse srv\n");
return -1;
}
if (strlen(c->host)) if (strlen(c->host))
return 1; return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment