[asterisk-commits] trunk r37286 - in /trunk: dns.c enum.c include/asterisk/dns.h

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jul 6 23:55:49 MST 2006


Author: russell
Date: Fri Jul  7 01:55:48 2006
New Revision: 37286

URL: http://svn.digium.com/view/asterisk?rev=37286&view=rev
Log:
fix various pointer signedness issues

Modified:
    trunk/dns.c
    trunk/enum.c
    trunk/include/asterisk/dns.h

Modified: trunk/dns.c
URL: http://svn.digium.com/view/asterisk/trunk/dns.c?rev=37286&r1=37285&r2=37286&view=diff
==============================================================================
--- trunk/dns.c (original)
+++ trunk/dns.c Fri Jul  7 01:55:48 2006
@@ -91,7 +91,7 @@
 	unsigned short size;
 } __attribute__ ((__packed__));
 
-static int skip_name(char *s, int len)
+static int skip_name(unsigned char *s, int len)
 {
 	int x = 0;
 
@@ -116,10 +116,10 @@
 
 /*! \brief Parse DNS lookup result, call callback */
 static int dns_parse_answer(void *context,
-	int class, int type, char *answer, int len,
-	int (*callback)(void *context, char *answer, int len, char *fullanswer))
+	int class, int type, unsigned char *answer, int len,
+	int (*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer))
 {
-	char *fullanswer = answer;
+	unsigned char *fullanswer = answer;
 	struct dn_answer *ans;
 	dns_HEADER *h;
 	int res;
@@ -192,12 +192,12 @@
 */
 int ast_search_dns(void *context,
 	   const char *dname, int class, int type,
-	   int (*callback)(void *context, char *answer, int len, char *fullanswer))
+	   int (*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer))
 {
 #ifdef HAS_RES_NINIT
 	struct __res_state dnsstate;
 #endif
-	char answer[MAX_SIZE];
+	unsigned char answer[MAX_SIZE];
 	int res, ret = -1;
 
 #ifdef HAS_RES_NINIT
@@ -205,7 +205,7 @@
 	memset(&dnsstate, 0, sizeof(dnsstate));
 #endif	
 	res_ninit(&dnsstate);
-	res = res_nsearch(&dnsstate, dname, class, type, (unsigned char *)answer, sizeof(answer));
+	res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer));
 #else
 	ast_mutex_lock(&res_lock);
 	res_init();

Modified: trunk/enum.c
URL: http://svn.digium.com/view/asterisk/trunk/enum.c?rev=37286&r1=37285&r2=37286&view=diff
==============================================================================
--- trunk/enum.c (original)
+++ trunk/enum.c Fri Jul  7 01:55:48 2006
@@ -95,7 +95,7 @@
 } __attribute__ ((__packed__));
 
 /*! \brief Parse NAPTR record information elements */
-static unsigned int parse_ie(char *data, unsigned int maxdatalen, char *src, unsigned int srclen)
+static unsigned int parse_ie(char *data, unsigned int maxdatalen, unsigned char *src, unsigned int srclen)
 {
 	unsigned int len, olen;
 
@@ -116,10 +116,10 @@
 }
 
 /*! \brief Parse DNS NAPTR record used in ENUM ---*/
-static int parse_naptr(unsigned char *dst, int dstsize, char *tech, int techsize, unsigned char *answer, int len, unsigned char *naptrinput)
+static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, unsigned char *answer, int len, char *naptrinput)
 {
 	char tech_return[80];
-	char *oanswer = answer;
+	unsigned char *oanswer = answer;
 	char flags[512] = "";
 	char services[512] = "";
 	char *p;
@@ -167,7 +167,7 @@
 		len -= res;
 	}
 
-	if ((res = dn_expand((unsigned char *)oanswer, (unsigned char *)answer + len, (unsigned char *)answer, repl, sizeof(repl) - 1)) < 0) {
+	if ((res = dn_expand(oanswer, answer + len, answer, repl, sizeof(repl) - 1)) < 0) {
 		ast_log(LOG_WARNING, "Failed to expand hostname\n");
 		return -1;
 	}
@@ -324,7 +324,7 @@
 };
 
 /*! \brief Callback for TXT record lookup */
-static int txt_callback(void *context, char *answer, int len, char *fullanswer)
+static int txt_callback(void *context, unsigned char *answer, int len, unsigned char *fullanswer)
 {
 	struct enum_context *c = (struct enum_context *)context;
 #if 0
@@ -350,7 +350,7 @@
 	len +=1;
 
 	/* finally, copy the answer into c->txt */
-	ast_copy_string(c->txt, answer, len < c->txtlen ? len : (c->txtlen));
+	ast_copy_string(c->txt, (const char *) answer, len < c->txtlen ? len : (c->txtlen));
 
 	/* just to be safe, let's make sure c->txt is null terminated */
 	c->txt[(c->txtlen)-1] = '\0';
@@ -359,7 +359,7 @@
 }
 
 /*! \brief Callback from ENUM lookup function */
-static int enum_callback(void *context, char *answer, int len, char *fullanswer)
+static int enum_callback(void *context, unsigned char *answer, int len, unsigned char *fullanswer)
 {
        struct enum_context *c = context;
        void *p = NULL;

Modified: trunk/include/asterisk/dns.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/dns.h?rev=37286&r1=37285&r2=37286&view=diff
==============================================================================
--- trunk/include/asterisk/dns.h (original)
+++ trunk/include/asterisk/dns.h Fri Jul  7 01:55:48 2006
@@ -36,6 +36,6 @@
 		services does not work, Asterisk may lock while waiting for response.
 */
 int ast_search_dns(void *context, const char *dname, int class, int type,
-	 int (*callback)(void *context, char *answer, int len, char *fullanswer));
+	 int (*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer));
 
 #endif /* _ASTERISK_DNS_H */



More information about the asterisk-commits mailing list