From 07c94b7319c269a951d48c32a3c959f569287089 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Tue, 31 Oct 2017 07:24:53 +0100 Subject: [PATCH] Added patch to fix sofia-sip compiler issue --- sip.cpp | 14 ++++++++++++ sofia-sip-gcc-4.8.patch | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 sofia-sip-gcc-4.8.patch diff --git a/sip.cpp b/sip.cpp index 6dbb4b3..075447c 100644 --- a/sip.cpp +++ b/sip.cpp @@ -15,6 +15,14 @@ #include #include +#ifndef SOFIA_SIP_GCC_4_8_PATCH_APLLIED +#warning ******************************************************** +#warning Please apply the sofia-sip-gcc-4.8.patch ! +#warning If this issue is already fixed, just remove this check. +#warning ******************************************************** +#error +#endif + #undef NUTAG_AUTO100 unsigned char flip[256]; @@ -851,6 +859,12 @@ int Psip::message_connect(unsigned int epoint_id, int message_id, union paramete , inet_ntoa(ia), inet_ntoa(ia), p_s_rtp_port_local, payload_type, payload_type, media_type2name(media_type)); PDEBUG(DEBUG_SIP, "Using SDP response: %s\n", sdp_str); + /* NOTE: + * If this response causes corrupt messages, like SDP body inside or + * before header, check if the sofia-sip-gcc-4.8.patch was applied. + * If it is still corrupted, try to disable optimization when compiling + * sofia-sip. + */ nua_respond(p_s_handle, SIP_200_OK, NUTAG_MEDIA_ENABLE(0), SIPTAG_CONTENT_TYPE_STR("application/sdp"), diff --git a/sofia-sip-gcc-4.8.patch b/sofia-sip-gcc-4.8.patch new file mode 100644 index 0000000..dad2b77 --- /dev/null +++ b/sofia-sip-gcc-4.8.patch @@ -0,0 +1,59 @@ +From cfeb1a1ee25865b2d8ba7b8a5ea4ad815077b353 Mon Sep 17 00:00:00 2001 +From: Arsen Chaloyan +Date: Wed, 23 Apr 2014 13:33:03 -0700 +Subject: [PATCH] Comply with the aggressive-loop-optimization introduced in + gcc 4.8. + +The problem is in gcc loop optimizers which detect a loop operating with out of bounds memory and then optimize it with something undefined since, according to the C standard, out of bounds behavior is undefined. The problem could have been addressed by using the new option -fno-aggressive-loop-optimization as well. +--- + libsofia-sip-ua/msg/msg_parser.c | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +diff --git a/libsofia-sip-ua/msg/msg_parser.c b/libsofia-sip-ua/msg/msg_parser.c +index 6f796eb..76185f3 100644 +--- a/libsofia-sip-ua/msg/msg_parser.c ++++ b/libsofia-sip-ua/msg/msg_parser.c +@@ -2530,8 +2530,6 @@ int msg_header_prepend(msg_t *msg, + msg_header_t ** + msg_hclass_offset(msg_mclass_t const *mc, msg_pub_t const *mo, msg_hclass_t *hc) + { +- int i; +- + assert(mc && hc); + + if (mc == NULL || hc == NULL) +@@ -2543,12 +2541,16 @@ msg_hclass_offset(msg_mclass_t const *mc, msg_pub_t const *mo, msg_hclass_t *hc) + if (mc->mc_hash[j].hr_class == hc) { + return (msg_header_t **)((char *)mo + mc->mc_hash[j].hr_offset); + } +- } +- else ++ } else { + /* Header has no name. */ +- for (i = 0; i <= 6; i++) +- if (hc->hc_hash == mc->mc_request[i].hr_class->hc_hash) +- return (msg_header_t **)((char *)mo + mc->mc_request[i].hr_offset); ++ if (hc->hc_hash == mc->mc_request[0].hr_class->hc_hash) return (msg_header_t **)((char *)mo + mc->mc_request[0].hr_offset); ++ if (hc->hc_hash == mc->mc_status[0].hr_class->hc_hash) return (msg_header_t **)((char *)mo + mc->mc_status[0].hr_offset); ++ if (hc->hc_hash == mc->mc_separator[0].hr_class->hc_hash) return (msg_header_t **)((char *)mo + mc->mc_separator[0].hr_offset); ++ if (hc->hc_hash == mc->mc_payload[0].hr_class->hc_hash) return (msg_header_t **)((char *)mo + mc->mc_payload[0].hr_offset); ++ if (hc->hc_hash == mc->mc_unknown[0].hr_class->hc_hash) return (msg_header_t **)((char *)mo + mc->mc_unknown[0].hr_offset); ++ if (hc->hc_hash == mc->mc_error[0].hr_class->hc_hash) return (msg_header_t **)((char *)mo + mc->mc_error[0].hr_offset); ++ if (hc->hc_hash == mc->mc_multipart[0].hr_class->hc_hash) return (msg_header_t **)((char *)mo + mc->mc_multipart[0].hr_offset); ++ } + + return NULL; + } +diff --git a/libsofia-sip-ua/sip/sofia-sip/sip.h b/libsofia-sip-ua/sip/sofia-sip/sip.h +index 793af0e..e8f3a4b 100644 +--- a/libsofia-sip-ua/sip/sofia-sip/sip.h ++++ b/libsofia-sip-ua/sip/sofia-sip/sip.h +@@ -26,6 +26,8 @@ + /** Defined when has been included. */ + #define SIP_H + ++#define SOFIA_SIP_GCC_4_8_PATCH_APLLIED ++ + /**@file sofia-sip/sip.h + * + * SIP objects. -- 2.13.6