[Freeswitch-svn] [commit] r8619 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/sresolv

Freeswitch SVN mikej at freeswitch.org
Sun May 25 11:07:50 EDT 2008


Author: mikej
Date: Sun May 25 11:07:50 2008
New Revision: 8619

Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c

Log:
Tue May 20 12:15:30 EDT 2008  Pekka.Pessi at nokia.com
  * sres.c: fixed klocwork issues


Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Sun May 25 11:07:50 2008
@@ -1 +1 @@
-Sun May 25 11:06:22 EDT 2008
+Sun May 25 11:07:19 EDT 2008

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	Sun May 25 11:07:50 2008
@@ -1026,7 +1026,10 @@
   if (res->res_n_servers == 0)
     return (void)su_seterrno(ENETDOWN), (sres_query_t *)NULL;
 
-  if (sres_has_search_domain(res))
+  if (domain[dlen - 1] == '.')
+    /* Domain ends with dot - do not search */
+    dots = res->res_config->c_opt.ndots;
+  else if (sres_has_search_domain(res))
     for (dots = 0, dot = strchr(domain, '.');
 	 dots < res->res_config->c_opt.ndots && dot; 
 	 dots++, dot = strchr(dot + 1, '.'))
@@ -1045,6 +1048,8 @@
       char const *const *domains = res->res_config->c_search;
       char search[SRES_MAXDNAME + 1];
 
+      assert(dlen < SRES_MAXDNAME);
+
       memcpy(search, domain, dlen);
       search[dlen++] = '.';
       search[dlen] = '\0';
@@ -1062,7 +1067,9 @@
 	  sub = sres_query_alloc(res, sres_answer_subquery, (void *)query,
 				 type, search);
 
-	  if (sres_send_dns_query(res, sub) == 0) {
+	  if (sub == NULL) {
+	  }
+	  else if (sres_send_dns_query(res, sub) == 0) {
 	    query->q_subqueries[i] = sub;
 	  }
 	  else {
@@ -1430,7 +1437,10 @@
 {		    
   int i, n;
 
-  for (n = 0, i = 0; answers && answers[i]; i++) {
+  if (res == NULL || answers == NULL)
+    return su_seterrno(EFAULT);
+
+  for (n = 0, i = 0; answers[i]; i++) {
     if (answers[i]->sr_record->r_status ||
 	answers[i]->sr_record->r_class != sres_class_in ||
 	(type != 0 && answers[i]->sr_record->r_type != type)) {
@@ -2010,6 +2020,10 @@
     if (name_servers_length > MAX_DATALEN) break;
 
     name_servers = su_realloc(home, name_servers, name_servers_length);
+    if (name_servers == NULL) {
+      ret = ERROR_BUFFER_OVERFLOW;
+      break;
+    }
   }
 
   /* if reading the key was succesful, continue */
@@ -3411,23 +3425,26 @@
 #define ADDRSIZE 48
 #endif
     char host[ADDRSIZE] = "*";
+    uint16_t port = 0;
 
     if (from == NULL)
       ;
     else if (from->ss_family == AF_INET) {
       struct sockaddr_in const *sin = (void *)from;
       su_inet_ntop(AF_INET, &sin->sin_addr, host, sizeof host);
+      port = sin->sin_port;
     } 
 #if HAVE_SIN6
     else if (from->ss_family == AF_INET6) {
       struct sockaddr_in6 const *sin6 = (void *)from;
       su_inet_ntop(AF_INET6, &sin6->sin6_addr, host, sizeof host);
+      port = sin6->sin6_port;
     }
 #endif
 
     SU_DEBUG_5(("sres_resolver_receive(%p, %p) id=%u (from [%s]:%u)\n", 
 		(void *)res, (void *)query, m->m_id, 
-		host, ntohs(((struct sockaddr_in *)from)->sin_port)));
+		host, ntohs(port)));
   }
 }
 
@@ -3447,7 +3464,7 @@
 {
   sres_record_t *rr = NULL, **answers = NULL, *error = NULL;
   sres_query_t *query = NULL, **hq;
-  su_home_t *chome = CHOME(res->res_cache);
+  su_home_t *chome;
   hash_value_t hash;
   int err;
   unsigned i, total, errorcount = 0;
@@ -3455,6 +3472,7 @@
   assert(res && m && return_answers);
 
   time(&res->res_now);
+  chome = CHOME(res->res_cache);
 
   *qq = NULL;
   *return_answers = NULL;
@@ -3737,8 +3755,9 @@
     a6->a6_suffix.u6_addr[i] = m_get_uint8(m);
 
   if (a6->a6_prelen > 0) {
-    /* Zero pad bits */
-    a6->a6_suffix.u6_addr[16 - suffixlen] &= 0xff >> (a6->a6_prelen & 7);
+    if (suffixlen > 0)
+      /* Zero pad bits */
+      a6->a6_suffix.u6_addr[16 - suffixlen] &= 0xff >> (a6->a6_prelen & 7);
 
     offset = m->m_offset, prefixlen = m_get_domain(NULL, 0, m, 0) + 1;
 



More information about the Freeswitch-svn mailing list