Added patch to fix sofia-sip compiler issue

This commit is contained in:
Andreas Eversberg 2017-10-31 07:24:53 +01:00
parent cdca6a7135
commit 07c94b7319
2 changed files with 73 additions and 0 deletions

14
sip.cpp
View File

@ -15,6 +15,14 @@
#include <sofia-sip/sdp.h>
#include <sofia-sip/sip_header.h>
#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"),

59
sofia-sip-gcc-4.8.patch Normal file
View File

@ -0,0 +1,59 @@
From cfeb1a1ee25865b2d8ba7b8a5ea4ad815077b353 Mon Sep 17 00:00:00 2001
From: Arsen Chaloyan <achaloyan@gmail.com>
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 <sofia-sip/sip.h> has been included. */
#define SIP_H
+#define SOFIA_SIP_GCC_4_8_PATCH_APLLIED
+
/**@file sofia-sip/sip.h
*
* SIP objects.