[asterisk-commits] file: branch group/dns r432524 - /team/group/dns/main/dns_core.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 6 12:24:31 CST 2015


Author: file
Date: Fri Mar  6 12:24:29 2015
New Revision: 432524

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=432524
Log:
Perform sanity checks on values passed into the resolve functions.

Modified:
    team/group/dns/main/dns_core.c

Modified: team/group/dns/main/dns_core.c
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/main/dns_core.c?view=diff&rev=432524&r1=432523&r2=432524
==============================================================================
--- team/group/dns/main/dns_core.c (original)
+++ team/group/dns/main/dns_core.c Fri Mar  6 12:24:29 2015
@@ -144,7 +144,27 @@
 {
 	struct ast_dns_query *query;
 
-	if (ast_strlen_zero(name) || !callback) {
+	if (ast_strlen_zero(name)) {
+		ast_log(LOG_ERROR, "Could not perform asynchronous resolution, no name provided\n");
+		return NULL;
+	} else if (rr_type > ns_t_max) {
+		ast_log(LOG_ERROR, "Could not perform asynchronous resolution, resource record type '%d' exceeds maximum\n",
+			rr_type);
+		return NULL;
+	} else if (rr_type < 0) {
+		ast_log(LOG_ERROR, "Could not perform asynchronous resolution, invalid resource record type '%d'\n",
+			rr_type);
+		return NULL;
+	} else if (rr_class > ns_c_max) {
+		ast_log(LOG_ERROR, "Could not perform asynchronous resolution, resource record class '%d' exceeds maximum\n",
+			rr_class);
+		return NULL;
+	} else if (rr_class < 0) {
+		ast_log(LOG_ERROR, "Could not perform asynchronous resolution, invalid resource class '%d'\n",
+			rr_class);
+		return NULL;
+	} else if (!callback) {
+		ast_log(LOG_ERROR, "Could not perform asynchronous resolution, no callback provided\n");
 		return NULL;
 	}
 
@@ -226,6 +246,27 @@
 	struct dns_synchronous_resolve *synchronous;
 	struct ast_dns_query *query;
 
+	if (ast_strlen_zero(name)) {
+		ast_log(LOG_ERROR, "Could not perform synchronous resolution, no name provided\n");
+		return -1;
+	} else if (rr_type > ns_t_max) {
+		ast_log(LOG_ERROR, "Could not perform synchronous resolution, resource record type '%d' exceeds maximum\n",
+			rr_type);
+		return -1;
+	} else if (rr_type < 0) {
+		ast_log(LOG_ERROR, "Could not perform synchronous resolution, invalid resource record type '%d'\n",
+			rr_type);
+		return -1;
+	} else if (rr_class > ns_c_max) {
+		ast_log(LOG_ERROR, "Could not perform synchronous resolution, resource record class '%d' exceeds maximum\n",
+			rr_class);
+		return -1;
+	} else if (rr_class < 0) {
+		ast_log(LOG_ERROR, "Could not perform synchronous resolution, invalid resource class '%d'\n",
+			rr_class);
+		return -1;
+	}
+
 	synchronous = ao2_alloc_options(sizeof(*synchronous), dns_synchronous_resolve_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
 	if (!synchronous) {
 		return -1;




More information about the asterisk-commits mailing list