aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authortwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-20 23:51:38 +0000
committertwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-20 23:51:38 +0000
commit83e3319215f2808100cd4470075fd81f76e601e8 (patch)
treeb1c249dbeec49f2b3c6ef2740a92541729dceb5d /main
parentf112a583f8f1d44193d3e6d24dd4d04c220b4cf7 (diff)
Avoid infinite loop with certain local channel connected line updates
Compare connected line data before sending a connected line indication to avoid possible loops. Review: https://reviewboard.asterisk.org/r/932/ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.8@287757 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/channel.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/main/channel.c b/main/channel.c
index b332dce1e..6e3758763 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -8227,11 +8227,38 @@ int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, str
return 0;
}
+/*! \brief Determine if two ast_party_connected_line structures differ
+ *
+ * \param c1 One of the structs to compare
+ * \param c2 The other struct to compare
+ * \retval 0 No difference or one of the structs is NULL
+ * \retval non-zero The structs differ
+ */
+static int connected_line_differ(const struct ast_party_connected_line *c1, const struct ast_party_connected_line *c2)
+{
+ unsigned char buf1[1024] = { 0, };
+ unsigned char buf2[sizeof(buf1)] = { 0, };
+
+ if (!c1 || !c2) {
+ return 0;
+ }
+
+ ast_connected_line_build_data(buf1, sizeof(buf1), c1, NULL);
+ ast_connected_line_build_data(buf2, sizeof(buf2), c2, NULL);
+
+ return memcmp(buf1, buf2, sizeof(buf1));
+}
+
void ast_channel_update_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
{
unsigned char data[1024]; /* This should be large enough */
size_t datalen;
+ if (!connected_line_differ(&chan->connected, connected)) {
+ ast_debug(1, "No change, so ignoring update\n");
+ return;
+ }
+
datalen = ast_connected_line_build_data(data, sizeof(data), connected, update);
if (datalen == (size_t) -1) {
return;