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

FreeSWITCH SVN mikej at freeswitch.org
Fri May 15 09:09:12 PDT 2009


Author: mikej
Date: Fri May 15 11:09:12 2009
New Revision: 13341

Log:
Wed May 13 11:37:19 CDT 2009  Pekka Pessi <first.last at nokia.com>
  * msg: unobfuscated casts of msg_header_t



Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_auth.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_basic.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_generic.c
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.c

Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Fri May 15 11:09:12 2009
@@ -1 +1 @@
-Fri May 15 11:07:28 CDT 2009
+Fri May 15 11:08:48 CDT 2009

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_auth.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_auth.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_auth.c	Fri May 15 11:09:12 2009
@@ -130,7 +130,7 @@
  */
 isize_t msg_auth_dup_xtra(msg_header_t const *h, isize_t offset)
 {
-  msg_auth_t const *au = h->sh_auth;
+  msg_auth_t const *au = (msg_auth_t *)h;
 
   MSG_PARAMS_SIZE(offset, au->au_params);
   offset += MSG_STRING_SIZE(au->au_scheme);
@@ -144,8 +144,8 @@
 		       char *b,
 		       isize_t xtra)
 {
-  msg_auth_t *au = dst->sh_auth;
-  msg_auth_t const *o = src->sh_auth;
+  msg_auth_t *au = (msg_auth_t *)dst;
+  msg_auth_t const *o = (msg_auth_t const *)src;
   char *end = b + xtra;
 
   b = msg_params_dup(&au->au_params, o->au_params, b, xtra);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_basic.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_basic.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_basic.c	Fri May 15 11:09:12 2009
@@ -235,8 +235,10 @@
 /** Parse payload. */
 issize_t msg_payload_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen)
 {
-  h->sh_payload->pl_len = slen;
-  h->sh_payload->pl_data = s;
+  msg_payload_t *pl = (msg_payload_t *)h;
+
+  pl->pl_len = slen;
+  pl->pl_data = s;
 
   h->sh_len = slen;
   h->sh_data = s;
@@ -246,11 +248,14 @@
 
 issize_t msg_payload_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
 {
-  size_t len = h->sh_payload->pl_len;
+  msg_payload_t *pl = (msg_payload_t *)h;
+  size_t len = pl->pl_len;
 
   if (bsiz > 0) {
-    memcpy(b, h->sh_payload->pl_data, bsiz > len ? len : bsiz);
-    b[bsiz > len ? len : bsiz - 1] = '\0';
+    if (len < bsiz)
+      memcpy(b, pl->pl_data, len), b[len] = '\0';
+    else
+      memcpy(b, pl->pl_data, bsiz - 1), b[bsiz - 1] = '\0';
   }
 
   return len;
@@ -258,7 +263,8 @@
 
 isize_t msg_payload_dup_xtra(msg_header_t const *h, isize_t offset)
 {
-  return offset + h->sh_payload->pl_len + 1;
+  msg_payload_t *pl = (msg_payload_t *)h;
+  return offset + pl->pl_len + 1;
 }
 
 char *msg_payload_dup_one(msg_header_t *dst,
@@ -266,13 +272,13 @@
 			  char *b,
 			  isize_t xtra)
 {
-  msg_payload_t *pl = dst->sh_payload;
-  msg_payload_t const *o = src->sh_payload;
+  msg_payload_t *pl = (msg_payload_t *)dst;
+  msg_payload_t const *o = (msg_payload_t const *)src;
 
   memcpy(pl->pl_data = b, o->pl_data, pl->pl_len = o->pl_len);
 
-  pl->pl_common->h_data = pl->pl_data;
-  pl->pl_common->h_len = pl->pl_len;
+  dst->sh_data = pl->pl_data;
+  dst->sh_len = pl->pl_len;
 
   pl->pl_data[pl->pl_len] = 0;	/* NUL terminate just in case */
 
@@ -322,12 +328,13 @@
 issize_t msg_separator_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen)
 {
   int len = CRLF_TEST(s);
+  msg_separator_t *sep = (msg_separator_t *)h;
 
   if (len == 0 && slen > 0)
     return -1;
 
-  memcpy(h->sh_separator->sep_data, s, len);
-  h->sh_separator->sep_data[len] = '\0';
+  memcpy(sep->sep_data, s, len);
+  sep->sep_data[len] = '\0';
 
   return 0;
 }
@@ -335,19 +342,20 @@
 /** Encode a separator line. */
 issize_t msg_separator_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
 {
-  size_t n = strlen(h->sh_separator->sep_data);
+  msg_separator_t const *sep = (msg_separator_t const *)h;
+  size_t n = strlen(sep->sep_data);
 
   if (bsiz > n)
-    strcpy(b, h->sh_separator->sep_data);
+    strcpy(b, sep->sep_data);
 
   return (issize_t)n;
 }
 
 msg_separator_t *msg_separator_create(su_home_t *home)
 {
-  msg_separator_t *sep =
-    msg_header_alloc(home, msg_separator_class, 0)->sh_separator;
+  msg_separator_t *sep;
 
+  sep = (msg_separator_t *)msg_header_alloc(home, msg_separator_class, 0);
   if (sep)
     strcpy(sep->sep_data, CRLF);
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_generic.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_generic.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_generic.c	Fri May 15 11:09:12 2009
@@ -68,7 +68,8 @@
 		       char *s,
 		       isize_t slen)
 {
-  h->sh_generic->g_string = s;
+  msg_generic_t *g = (msg_generic_t *)h;
+  g->g_string = s;
   return 0;
 }
 
@@ -80,7 +81,7 @@
  */
 issize_t msg_generic_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
 {
-  msg_generic_t const *g = h->sh_generic;
+  msg_generic_t const *g = (msg_generic_t const *)h;
   size_t n = strlen(g->g_string);
 
   if (bsiz > n)
@@ -92,7 +93,7 @@
 /** Calculate the size of strings associated with a @c msg_generic_t object. */
 isize_t msg_generic_dup_xtra(msg_header_t const *h, isize_t offset)
 {
-  msg_generic_t const *g = h->sh_generic;
+  msg_generic_t const *g = (msg_generic_t const *)h;
   return offset + MSG_STRING_SIZE(g->g_string);
 }
 
@@ -102,8 +103,10 @@
 			  char *b,
 			  isize_t xtra)
 {
+  msg_generic_t *g = (msg_generic_t *)dst;
+  msg_generic_t const *o = (msg_generic_t const *)src;
   char *end = b + xtra;
-  MSG_STRING_DUP(b, dst->sh_generic->g_string, src->sh_generic->g_string);
+  MSG_STRING_DUP(b, g->g_string, o->g_string);
   assert(b <= end); (void)end;
   return b;
 }
@@ -117,7 +120,7 @@
   uint32_t value = 0;
   issize_t retval = msg_uint32_d(&s, &value);
 
-  assert(x->x_common->h_class->hc_size >= sizeof *x);
+  assert(h->sh_class->hc_size >= sizeof *x);
 
   x->x_value = value;
 
@@ -150,15 +153,17 @@
 
 issize_t msg_list_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen)
 {
-  return msg_commalist_d(home, &s, &h->sh_list->k_items, NULL);
+  msg_list_t *k = (msg_list_t *)h;
+  return msg_commalist_d(home, &s, &k->k_items, NULL);
 }
 
 issize_t msg_list_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
 {
+  msg_list_t *k = (msg_list_t *)h;
   int compact = MSG_IS_COMPACT(flags);
   char *b0 = b, *end = b + bsiz;
 
-  MSG_COMMALIST_E(b, end, h->sh_list->k_items, compact);
+  MSG_COMMALIST_E(b, end, k->k_items, compact);
   MSG_TERM_E(b, end);
 
   return b - b0;
@@ -176,7 +181,8 @@
  */
 isize_t msg_list_dup_xtra(msg_header_t const *h, isize_t offset)
 {
-  MSG_PARAMS_SIZE(offset, h->sh_list->k_items);
+  msg_list_t const *k = (msg_list_t const *)h;
+  MSG_PARAMS_SIZE(offset, k->k_items);
   return offset;
 }
 
@@ -185,10 +191,12 @@
 		       char *b,
 		       isize_t xtra)
 {
+  msg_list_t *k = (msg_list_t *)dst;
+  msg_list_t const *o = (msg_list_t const *)src;
   char *end = b + xtra;
-  msg_param_t const ** items = (msg_param_t const **)&dst->sh_list->k_items;
+  msg_param_t const ** items = (msg_param_t const **)&k->k_items;
 
-  b = msg_params_dup(items, src->sh_list->k_items, b, xtra);
+  b = msg_params_dup(items, o->k_items, b, xtra);
 
   assert(b <= end); (void)end;
 

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser.c	Fri May 15 11:09:12 2009
@@ -1003,7 +1003,7 @@
 
 /** Extract a header. */
 issize_t msg_extract_header(msg_t *msg, msg_pub_t *mo,
-			   char b[], isize_t bsiz, int eos)
+			    char b[], isize_t bsiz, int eos)
 {
   return extract_header(msg, mo, b, bsiz, eos, 0);
 }
@@ -1143,6 +1143,7 @@
       /* XXX - This should be done by msg_header_free_all() */
       msg_header_t *h_next;
       msg_param_t *h_params;
+      msg_error_t *er;
 
       while (h) {
 	h_next = h->sh_next;
@@ -1157,10 +1158,12 @@
       /* XXX - This should be done by msg_header_free_all() */
       hr = msg->m_class->mc_error;
       h = msg_header_alloc(home, hr->hr_class, 0);
-      if (!h)
-	return h;
+      er = (msg_error_t *)h;
 
-      h->sh_error->er_name = hc->hc_name;
+      if (!er)
+	return NULL;
+
+      er->er_name = hc->hc_name;
       hh = (msg_header_t **)((char *)mo + hr->hr_offset);
     }
   }



More information about the Freeswitch-svn mailing list