]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[sofia-sip] Fix multiple issues reported by scan-build. 352/head
authorAndrey Volk <andywolk@gmail.com>
Thu, 13 Feb 2020 14:57:06 +0000 (18:57 +0400)
committerAndrey Volk <andywolk@gmail.com>
Thu, 13 Feb 2020 17:11:18 +0000 (21:11 +0400)
14 files changed:
libs/sofia-sip/.update
libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.c
libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c
libs/sofia-sip/libsofia-sip-ua/nea/nea_server.c
libs/sofia-sip/libsofia-sip-ua/nta/nta.c
libs/sofia-sip/libsofia-sip-ua/nth/nth_server.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_registrar.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
libs/sofia-sip/libsofia-sip-ua/sdp/sdp.c
libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c
libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c

index 31b25be307923b5cb2740761f5f685f378134b09..0d656974e6210ffcae5e88385b0cc753d1d6b5b2 100644 (file)
@@ -1 +1 @@
-Wed Feb 12 22:23:00 UTC 2020
+Thu Feb 13 14:53:01 UTC 2020
index ca904aea80989751e4f89f0114713deb9c01f420..2e3a8d42afd6cfd1ad6d69c11f666601b7a1639d 100644 (file)
@@ -1244,7 +1244,7 @@ issize_t msg_parse_next_field(su_home_t *home, msg_header_t *prev,
 msg_header_t *msg_header_d(su_home_t *home, msg_t const *msg, char const *b)
 {
   msg_mclass_t const *mc = msg->m_class;
-  msg_href_t const *hr = mc->mc_unknown;
+  msg_href_t const *hr;
   isize_t n;                   /* Length of header contents */
   isize_t name_len, xtra;
   msg_header_t *h;
index b64c4489dff53ac77da79d743e3494364657410e..109ee60ff51c3c2d25c267c95cb271b5a6101464 100644 (file)
@@ -1756,7 +1756,7 @@ issize_t msg_unquoted_e(char *b, isize_t bsiz, char const *s)
     size_t n = strcspn(s, "\"\\");
 
     if (n == 0) {
-      if (e + 2 <= bsiz)
+      if (b && e + 2 <= bsiz)
        b[e] = '\\', b[e + 1] = s[0];
       e += 2;
       s++;
@@ -1769,7 +1769,7 @@ issize_t msg_unquoted_e(char *b, isize_t bsiz, char const *s)
     }
   }
 
-  if (e < bsiz)
+  if (b && e < bsiz)
     b[e] = '"';
   e++;
 
index 42539cf82d64c0e3f66c311130c5c9fbfc2d8b76..4f1fce43a1b5c508e15f521e4987fc5e3ceb5f86 100644 (file)
@@ -844,7 +844,7 @@ int nea_view_update(nea_server_t *nes,
     nea_view_queue(nes, evv, evq);
 
   SU_DEBUG_7(("nea_server_update(%p): %s (%s)\n", (void *)nes,
-             ev->ev_event->o_type, evv->evv_content_type->c_type));
+             ev->ev_event->o_type, (evv->evv_content_type ? evv->evv_content_type->c_type : "N/A")));
 
   return 1;
 }
index 92c8dda444b830af2d4a40566ca9a893c8e2b734..70aa8d1e4d327205dce84ff9f8d3415427a586d1 100644 (file)
@@ -2406,6 +2406,11 @@ int agent_init_via(nta_agent_t *self, tport_t *primaries, int use_maddr)
     }
   }
 
+  if (!via) {
+      SU_DEBUG_9(("nta: agent_init_via failed\n" VA_NONE));
+      goto error;
+  }
+
   /* Duplicate the list bind to the transports */
   new_via = sip_via_dup(self->sa_home, via);
   /* Duplicate the complete list shown to the application */
@@ -3346,7 +3351,7 @@ void agent_recv_response(nta_agent_t *agent,
     return;
   }
 
-  if (sip->sip_cseq->cs_method == sip_method_ack) {
+  if (sip->sip_cseq && sip->sip_cseq->cs_method == sip_method_ack) {
     /* Drop response messages to ACK */
     agent->sa_stats->as_bad_response++;
     agent->sa_stats->as_bad_message++;
@@ -9160,7 +9165,7 @@ outgoing_remove_fork(nta_outgoing_t *orq)
   nta_outgoing_t **slot;
 
   for (slot = &orq->orq_forking->orq_forks;
-       *slot;
+       slot && *slot;
        slot = &(*slot)->orq_forks) {
     if (orq == *slot) {
       *slot = orq->orq_forks;
index bbc61c46deee562ca74bce98a949054ec5bd5ab2..5fcb15a5c61a39a2c0314715830fcfa36555aa04 100644 (file)
@@ -342,6 +342,13 @@ nth_site_t *nth_site_create(nth_site_t *parent,
       size_t i, j;
 
       path = (char *)url->url_path;
+
+      if (!path) {
+          SU_DEBUG_3(("nth_site_create(): invalid url\n" VA_NONE));
+          errno = EINVAL;
+          goto error;
+      }
+
       while (path[0] == '/')
        path++;
 
@@ -842,10 +849,10 @@ void server_request(server_t *srv,
 
   if (subsite)
     subsite->site_access = now;
-  else
+  else if (site)
     site->site_access = now;
 
-  if (subsite && subsite->site_isdir && subpath == site_nodir_match) {
+  if (site && subsite && subsite->site_isdir && subpath == site_nodir_match) {
     /* Answer with 301 */
     http_location_t loc[1];
     http_location_init(loc);
index 8ef6747aff9d393052a83e5efbe6419969f59c61..97247f9d6de4e2949ab17b4c5e0dacbec146901d 100644 (file)
@@ -853,6 +853,9 @@ static int nua_notify_usage_shutdown(nua_handle_t *nh,
   struct notifier_usage *nu = nua_dialog_usage_private(du);
   //nua_client_request_t *cr = du->du_cr;
 
+  if (!nu)
+    return -1;
+
   nu->nu_substate = nua_substate_terminated;
 #if 0
   if (cr) {
index 2d21acbaa28dee6ae24284d255424648682da95a..2140eff7da8a9b37f229bc3dcc080193a5697e65 100644 (file)
@@ -1122,7 +1122,7 @@ int nhp_save_params(nua_handle_t *nh,
   su_home_t *home = nh->nh_home;
   nua_t *nua = nh->nh_nua;
   nua_handle_t *dnh = nua->nua_dhandle;
-  nua_handle_preferences_t *dst = nh->nh_prefs, old[1];
+  nua_handle_preferences_t *dst, old[1];
 
   if (gsrc) {
     *nua->nua_prefs = *gsrc;   /* No pointers this far */
index fbef0166c88bef50787b66a3c9a664a22c25f3b6..a57b511005e4c9e4e1fd6890385ba4f15c82a07b 100644 (file)
@@ -86,6 +86,9 @@ static void nua_registrar_usage_remove(nua_handle_t *nh,
 
   ru = nua_dialog_usage_private(du);
 
+  if (!ru)
+    return;
+
   if (ru->pending)
     tport_release(ru->tport, ru->pending, NULL, NULL, nh, 0), ru->pending = 0;
 
index d4deed535a41333f98b11f1c6176ef380eeca68d..08bc8b692647ed393d5c4a626947445b4afcd016 100644 (file)
@@ -3601,8 +3601,11 @@ int nua_update_server_respond(nua_server_request_t *sr, tagi_t const *tags)
       sr_status(sr, SIP_500_INTERNAL_SERVER_ERROR);
     }
     else {
-      sr->sr_answer_sent = 1, ss->ss_oa_sent = Answer;
-      ss->ss_sdp_version = soa_get_user_version(nh->nh_soa);
+      sr->sr_answer_sent = 1;
+      if (ss) {
+        ss->ss_oa_sent = Answer;
+        ss->ss_sdp_version = soa_get_user_version(nh->nh_soa);
+      }
     }
   }
 
index cdd3a191aeb2cf078548a9cfa521ce72bd3a98c3..696827d91d535c654f5f1b5e0a0c963c0c46b6b6 100644 (file)
@@ -667,8 +667,10 @@ void nua_stack_signal(nua_t *nua, su_msg_r msg, nua_ee_data_t *ee)
   }
 
   if (error < 0) {
-    nua_stack_event(nh->nh_nua, nh, NULL, event,
+    if (nh) {
+      nua_stack_event(nh->nh_nua, nh, NULL, event,
                    NUA_ERROR_AT(__FILE__, __LINE__), NULL);
+    }
   }
 
   su_msg_destroy(nua->nua_signal);
index 0e248c69df07006cac039c3eba86152eb16ec70e..8ed84ff3572144757ab3d6fd45cb8dc538cae9d4 100644 (file)
@@ -1370,6 +1370,9 @@ int sdp_key_cmp(sdp_key_t const *a, sdp_key_t const *b)
   if ((a != NULL) != (b != NULL))
     return (a != NULL) < (b != NULL) ? -1 : 1;
 
+  if (!a || !b)
+    return -1;
+
   if (a->k_method != b->k_method)
     return a->k_method < b->k_method ? -1 : 1;
   if (a->k_method == sdp_key_x &&
index e5ef095eb0bceebf5e2330940ff11d801628907f..a58179157476f52d23e2f9ade007293dfa85c75c 100644 (file)
@@ -257,9 +257,11 @@ sip_contact_string_from_via(su_home_t *home,
 
   /* Make transport parameter lowercase */
   if (transport && strlen(transport) < (sizeof _transport)) {
-    char *s = strcpy(_transport, transport);
+    char *s;
     short c;
 
+    strcpy(_transport, transport);
+
     for (s = _transport; (c = *s) && c != ';'; s++)
       if (isupper(c))
        *s = tolower(c);
index 47e951f1445fa3587d639fdd582377e914980dca..492900f16e79ae83c1e70ca3d8d22dcde4081f91 100644 (file)
@@ -228,11 +228,15 @@ int su_getlocalinfo(su_localinfo_t const *hints,
 #endif
 
   case AF_INET:
+#ifndef USE_LOCALINFO0
     ip4 = 1;
+#endif
     break;
 
   case 0:
+#ifndef USE_LOCALINFO0
     ip4 = 1;
+#endif
 #if SU_HAVE_IN6  
     ip6 = 1;
 #endif