diff --git a/debian/patches/series b/debian/patches/series index 6cb221077..d7da921e0 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -4,8 +4,16 @@ upstream/0001-tm-apply-new-updates-with-Via-with-updated-request.patch upstream/0002-presence-free-pointer-after-usage.patch upstream/0003-htable-use-custom-column-name-for-order-by-in-db-loa.patch -# -sipwise/presence-remove-transaction-creation-from-publ_notif.patch +upstream/0004-topoh-safety-check-to-avoid-crash-when-there-is-no-v.patch +upstream/0005-kazoo-fix-compiler-warning-json_obj-may-be-used-unin.patch +upstream/0006-core-avoid-overrun-buffer-arg.patch +upstream/0007-http_async_client-handle-100-Continue-from-server.patch +upstream/0008-rtpengine-fix-segfault-when-enabling-a-proxy.patch +upstream/0015-core-free-parsed-Required-header-structure.patch +upstream/0016-sanity-reset-proxy_require-hdr-parsed-field-after-fr.patch +upstream/0017-pua_reginfo-fix-memory-leak-when-usrloc-is-DB_ONLY.patch +upstream/0018-usrloc-fix-ucontact-shared-leak.patch +upstream/0019-presence-remove-transaction-creation-from-publ_notif.patch # upsream fixes from master upstream/pv-new-function-pv_evalx-dst-fmt.patch # @@ -40,5 +48,4 @@ sipwise/sca-use-To-header-if-in-dialog-as-target.patch sipwise/sca-fix-sca_call_info_update-params.patch sipwise/sca-use-onhold_bflag-value-only-when-set.patch ## -sipwise/rtpengine-sockets-list-fix.patch sipwise/tm-deep-cloning-of-the-request-for-fake-environment.patch diff --git a/debian/patches/upstream/0004-topoh-safety-check-to-avoid-crash-when-there-is-no-v.patch b/debian/patches/upstream/0004-topoh-safety-check-to-avoid-crash-when-there-is-no-v.patch new file mode 100644 index 000000000..b7682e68e --- /dev/null +++ b/debian/patches/upstream/0004-topoh-safety-check-to-avoid-crash-when-there-is-no-v.patch @@ -0,0 +1,31 @@ +From 4180f5bf64b6b4338f99ba0eb7d2146ef86c088e Mon Sep 17 00:00:00 2001 +From: Minh Phan +Date: Fri, 27 Jan 2017 09:06:08 +0100 +Subject: [PATCH] topoh: safety check to avoid crash when there is no via + header + +- based on GH #952 + +(cherry picked from commit 2367fb52aa94bd06fcbadce7f9ecccdcf6e36c83) +--- + modules/topoh/th_msg.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/modules/topoh/th_msg.c b/modules/topoh/th_msg.c +index 40a956e81..a070c2705 100644 +--- a/modules/topoh/th_msg.c ++++ b/modules/topoh/th_msg.c +@@ -954,6 +954,10 @@ int th_add_hdr_cookie(sip_msg_t *msg) + struct via_param *th_get_via_cookie(sip_msg_t *msg, struct via_body *via) + { + struct via_param *p; ++ ++ if (!via) { ++ return NULL; ++ } + for(p=via->param_lst; p; p=p->next) + { + if(p->name.len==th_cookie_name.len +-- +2.11.0 + diff --git a/debian/patches/upstream/0005-kazoo-fix-compiler-warning-json_obj-may-be-used-unin.patch b/debian/patches/upstream/0005-kazoo-fix-compiler-warning-json_obj-may-be-used-unin.patch new file mode 100644 index 000000000..ba7d8d7c4 --- /dev/null +++ b/debian/patches/upstream/0005-kazoo-fix-compiler-warning-json_obj-may-be-used-unin.patch @@ -0,0 +1,37 @@ +From 76765a2e5ca9649d19c3b49a5122e4eaa68e8778 Mon Sep 17 00:00:00 2001 +From: Ovidiu Sas +Date: Mon, 30 Jan 2017 15:26:30 -0500 +Subject: [PATCH] =?UTF-8?q?kazoo:=20fix=20compiler=20warning:=20=E2=80=98j?= + =?UTF-8?q?son=5Fobj=E2=80=99=20may=20be=20used=20uninitialized=20in=20thi?= + =?UTF-8?q?s=20function=20[-Wuninitialized]=20=20-=20closes=20#954?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + modules/kazoo/kz_amqp.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/modules/kazoo/kz_amqp.c b/modules/kazoo/kz_amqp.c +index 2b8a5e905..69127cfa3 100644 +--- a/modules/kazoo/kz_amqp.c ++++ b/modules/kazoo/kz_amqp.c +@@ -2496,13 +2496,14 @@ void kz_send_targeted_cmd(int server_id, amqp_bytes_t body) + kz_amqp_cmd_ptr cmd = NULL; + json_object* JObj = NULL; + char* payload = kz_local_amqp_bytes_dup(body); ++ json_obj_ptr json_obj = NULL; + + if(payload == NULL) { + LM_ERR("error allocating message payload\n"); + goto error; + } + +- json_obj_ptr json_obj = kz_json_parse(payload ); ++ json_obj = kz_json_parse(payload ); + if (json_obj == NULL) { + LM_ERR("error parsing json payload\n"); + goto error; +-- +2.11.0 + diff --git a/debian/patches/upstream/0006-core-avoid-overrun-buffer-arg.patch b/debian/patches/upstream/0006-core-avoid-overrun-buffer-arg.patch new file mode 100644 index 000000000..8ccb43c60 --- /dev/null +++ b/debian/patches/upstream/0006-core-avoid-overrun-buffer-arg.patch @@ -0,0 +1,46 @@ +From 42f5515df93a182fd33a6c48f1a9dd1850e91965 Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Wed, 1 Feb 2017 12:53:28 +0100 +Subject: [PATCH] core: avoid overrun-buffer-arg + +> Overrunning array ((struct a_rdata *)rr->rdata)->ip of 4 bytes +> by passing it to a function which accesses it at byte offset 15 +> using argument len (which evaluates to 16) + +(cherry picked from commit 5640f696f5364bb88732807f5f87b4afb7a97ba6) +--- + dns_cache.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/dns_cache.c b/dns_cache.c +index 21b780ee0..c4b910d26 100644 +--- a/dns_cache.c ++++ b/dns_cache.c +@@ -2362,6 +2362,7 @@ inline static struct hostent* dns_entry2he(struct dns_hash_entry* e) + int af, len; + struct dns_rr* rr; + unsigned char rr_no; ++ unsigned char *ip; + ticks_t now; + int i; + +@@ -2389,7 +2390,15 @@ inline static struct hostent* dns_entry2he(struct dns_hash_entry* e) + for(i=0; rr && (irdata)->ip, len); ++ switch(e->type){ ++ case T_A: ++ ip = ((struct a_rdata*)rr->rdata)->ip; ++ break; ++ case T_AAAA: ++ ip = ((struct aaaa_rdata*)rr->rdata)->ip6; ++ break; ++ } ++ memcpy(p_addr[i], ip, len); + } + if (i==0){ + LM_DBG("no good records found (%d) for %.*s (%d)\n", +-- +2.11.0 + diff --git a/debian/patches/upstream/0007-http_async_client-handle-100-Continue-from-server.patch b/debian/patches/upstream/0007-http_async_client-handle-100-Continue-from-server.patch new file mode 100644 index 000000000..84c4fbdcd --- /dev/null +++ b/debian/patches/upstream/0007-http_async_client-handle-100-Continue-from-server.patch @@ -0,0 +1,72 @@ +From 6c6f25b581e083068e9b3832e8f0235a24a88021 Mon Sep 17 00:00:00 2001 +From: grumvalski +Date: Thu, 2 Feb 2017 15:28:16 +0100 +Subject: [PATCH] http_async_client: handle 100 Continue from server + +(cherry-picked from commit de1c5397847a3660182832a040d9e9c2e737e654) +--- + modules/http_async_client/async_http.c | 27 ++++++++++++++++++++++++--- + 1 file changed, 24 insertions(+), 3 deletions(-) + +diff --git a/modules/http_async_client/async_http.c b/modules/http_async_client/async_http.c +index 24dc8ba72..4b6c33c4f 100644 +--- a/modules/http_async_client/async_http.c ++++ b/modules/http_async_client/async_http.c +@@ -45,7 +45,7 @@ + #include "../../dprint.h" + #include "../../ut.h" + #include "../../cfg/cfg_struct.h" +-#include "../../lib/kcore/faked_msg.h" ++#include "../../fmsg.h" + #include "../../modules/tm/tm_load.h" + + #include "async_http.h" +@@ -122,6 +122,7 @@ void async_http_cb(struct http_m_reply *reply, void *param) + unsigned int tlabel; + struct cell *t = NULL; + char *p; ++ str newbuf = {0, 0}; + sip_msg_t *fmsg; + + if (reply->result != NULL) { +@@ -140,7 +141,6 @@ void async_http_cb(struct http_m_reply *reply, void *param) + ah_error.len = strlen(ah_error.s); + } else { + /* success */ +- + /* check for HTTP Via header + * - HTTP Via format is different that SIP Via + * - workaround: replace with Hia to be ignored by SIP parser +@@ -158,7 +158,28 @@ void async_http_cb(struct http_m_reply *reply, void *param) + if (parse_msg(reply->result->s, reply->result->len, ah_reply) != 0) { + LM_DBG("failed to parse the http_reply\n"); + } else { +- LM_DBG("successfully parsed http reply %p\n", ah_reply); ++ if (ah_reply->first_line.u.reply.statuscode == 100) { ++ newbuf.s = get_body( ah_reply ); ++ newbuf.len = reply->result->s + reply->result->len - newbuf.s; ++ ++ if (!(newbuf.len < 0)) { ++ memset(ah_reply, 0, sizeof(struct sip_msg)); ++ ah_reply->buf = newbuf.s; ++ ah_reply->len = newbuf.len; ++ ++ if (parse_msg(ah_reply->buf, ah_reply->len, ah_reply) != 0) { ++ LM_DBG("failed to parse the http_reply\n"); ++ } else { ++ LM_DBG("successfully parsed http reply %p\n", ah_reply); ++ } ++ } else { ++ /* this should not happen! */ ++ LM_WARN("something got wrong parsing the 100 Continue: got %d len\n", newbuf.len); ++ } ++ ++ } else { ++ LM_DBG("successfully parsed http reply %p\n", ah_reply); ++ } + } + } + +-- +2.11.0 + diff --git a/debian/patches/sipwise/rtpengine-sockets-list-fix.patch b/debian/patches/upstream/0008-rtpengine-fix-segfault-when-enabling-a-proxy.patch similarity index 75% rename from debian/patches/sipwise/rtpengine-sockets-list-fix.patch rename to debian/patches/upstream/0008-rtpengine-fix-segfault-when-enabling-a-proxy.patch index 9f109b316..599a8cc0c 100644 --- a/debian/patches/sipwise/rtpengine-sockets-list-fix.patch +++ b/debian/patches/upstream/0008-rtpengine-fix-segfault-when-enabling-a-proxy.patch @@ -1,6 +1,17 @@ +From a321025984d183f9c727fa4c9fcdc1e2e87010bf Mon Sep 17 00:00:00 2001 +From: Richard Fuchs +Date: Fri, 3 Feb 2017 10:10:23 -0500 +Subject: [PATCH] rtpengine: fix segfault when enabling a proxy + +--- + modules/rtpengine/rtpengine.c | 51 +++++++++++++++++-------------------------- + 1 file changed, 20 insertions(+), 31 deletions(-) + +diff --git a/modules/rtpengine/rtpengine.c b/modules/rtpengine/rtpengine.c +index 6b460743e..01f1606bf 100644 --- a/modules/rtpengine/rtpengine.c +++ b/modules/rtpengine/rtpengine.c -@@ -195,7 +195,7 @@ +@@ -194,7 +194,7 @@ static struct rtpp_node *select_rtpp_node_new(str, str, int, struct rtpp_node ** static struct rtpp_node *select_rtpp_node_old(str, str, int, enum rtpe_operation); static struct rtpp_node *select_rtpp_node(str, str, int, struct rtpp_node **, int, enum rtpe_operation); static int is_queried_node(struct rtpp_node *, struct rtpp_node **, int); @@ -9,7 +20,7 @@ static char *send_rtpp_command(struct rtpp_node *, bencode_item_t *, int *); static int get_extra_id(struct sip_msg* msg, str *id_str); -@@ -1069,6 +1069,9 @@ +@@ -1068,6 +1068,9 @@ static struct mi_root* mi_enable_rtp_proxy(struct mi_root *cmd_tree, void *param str rtpp_url; str snode, sattr, svalue; @@ -19,7 +30,7 @@ found = MI_FOUND_NONE; found_rtpp_disabled = 0; found_rtpp = NULL; -@@ -1413,6 +1416,9 @@ +@@ -1412,6 +1415,9 @@ static struct mi_root* mi_ping_rtp_proxy(struct mi_root* cmd_tree, void* param) str rtpp_url; str snode, sattr, svalue; @@ -29,7 +40,7 @@ found = 0; found_rtpp_disabled = 0; found_rtpp = NULL; -@@ -1577,7 +1583,6 @@ +@@ -1576,7 +1582,6 @@ static struct mi_root* mi_reload_rtp_proxy(struct mi_root* cmd_tree, void* param) { struct mi_root *root = NULL; @@ -37,7 +48,7 @@ if (rtpp_db_url.s == NULL) { // no database -@@ -1595,13 +1600,7 @@ +@@ -1594,13 +1599,7 @@ mi_reload_rtp_proxy(struct mi_root* cmd_tree, void* param) return 0; } } else { @@ -52,7 +63,7 @@ // success reloading from database root = init_mi_tree(200, MI_DB_OK, MI_DB_OK_LEN); -@@ -1796,16 +1795,24 @@ +@@ -1795,16 +1794,24 @@ mod_init(void) return 0; } @@ -78,7 +89,7 @@ // close current sockets for (i = 0; i < rtpp_socks_size; i++) { if (rtpp_socks[i] >= 0) { -@@ -1921,16 +1928,6 @@ +@@ -1920,16 +1927,6 @@ child_init(int rank) mypid = getpid(); @@ -95,7 +106,7 @@ // vector of pointers to queried nodes queried_nodes_ptr = (struct rtpp_node**)pkg_malloc(queried_nodes_limit * sizeof(struct rtpp_node*)); if (!queried_nodes_ptr) { -@@ -1940,9 +1937,8 @@ +@@ -1939,9 +1936,8 @@ child_init(int rank) memset(queried_nodes_ptr, 0, queried_nodes_limit * sizeof(struct rtpp_node*)); /* Iterate known RTP proxies - create sockets */ @@ -107,7 +118,7 @@ return 0; } -@@ -2867,15 +2863,8 @@ +@@ -2844,15 +2840,8 @@ static struct rtpp_node * select_rtpp_node(str callid, str viabranch, int do_test, struct rtpp_node **queried_nodes_ptr, int queried_nodes, enum rtpe_operation op) { struct rtpp_node *node = NULL; @@ -124,3 +135,6 @@ if (!active_rtpp_set) { default_rtpp_set = select_rtpp_set(setid_default); +-- +2.11.0 + diff --git a/debian/patches/upstream/0015-core-free-parsed-Required-header-structure.patch b/debian/patches/upstream/0015-core-free-parsed-Required-header-structure.patch new file mode 100644 index 000000000..54757bf66 --- /dev/null +++ b/debian/patches/upstream/0015-core-free-parsed-Required-header-structure.patch @@ -0,0 +1,56 @@ +From b81a228b5a680dff1dff911f1020c8494fbee935 Mon Sep 17 00:00:00 2001 +From: Daniel-Constantin Mierla +Date: Wed, 15 Feb 2017 12:48:59 +0100 +Subject: [PATCH] core: free parsed Required header structure + +(cherry picked from commit d31558b31fd607f842caa04d85ce8870f6fc1740) +(cherry picked from commit 8a02d964ffc6145b3ae2f349b8d25aff4dacde3a) +--- + parser/hf.c | 2 +- + parser/parse_require.c | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/parser/hf.c b/parser/hf.c +index 963dd1471..915a52d2c 100644 +--- a/parser/hf.c ++++ b/parser/hf.c +@@ -150,6 +150,7 @@ void clean_hdr_field(struct hdr_field* const hf) + free_subscription_state((subscription_state_t**)h_parsed); + break; + ++ case HDR_REQUIRE_T: + case HDR_SUPPORTED_T: + hdr_free_parsed(h_parsed); + break; +@@ -168,7 +169,6 @@ void clean_hdr_field(struct hdr_field* const hf) + case HDR_CONTENTTYPE_T: + case HDR_CONTENTLENGTH_T: + case HDR_RETRY_AFTER_T: +- case HDR_REQUIRE_T: + case HDR_PROXYREQUIRE_T: + case HDR_UNSUPPORTED_T: + case HDR_ACCEPTLANGUAGE_T: +diff --git a/parser/parse_require.c b/parser/parse_require.c +index a520318e1..e343e7f17 100644 +--- a/parser/parse_require.c ++++ b/parser/parse_require.c +@@ -1,6 +1,6 @@ + /* + * Copyright (C) 2006 Andreas Granig +- * ++ * + * This file is part of Kamailio, a free SIP server. + * + * Kamailio is free software; you can redistribute it and/or modify +@@ -65,7 +65,7 @@ int parse_require( struct sip_msg *msg) + require |= rb->option_tags; + } + +- ((struct option_tag_body*)msg->require->parsed)->option_tags_all = ++ ((struct option_tag_body*)msg->require->parsed)->option_tags_all = + require; + return 0; + } +-- +2.11.0 + diff --git a/debian/patches/upstream/0016-sanity-reset-proxy_require-hdr-parsed-field-after-fr.patch b/debian/patches/upstream/0016-sanity-reset-proxy_require-hdr-parsed-field-after-fr.patch new file mode 100644 index 000000000..76a195b9c --- /dev/null +++ b/debian/patches/upstream/0016-sanity-reset-proxy_require-hdr-parsed-field-after-fr.patch @@ -0,0 +1,26 @@ +From 4844facff6b6ae66d7d1d9abd3c45bd470d5dfdc Mon Sep 17 00:00:00 2001 +From: Daniel-Constantin Mierla +Date: Wed, 15 Feb 2017 12:53:59 +0100 +Subject: [PATCH] sanity: reset proxy_require hdr parsed field after freeing + +(cherry picked from commit 06e219158131c2397a96bf5d3373c96752d7fd20) +(cherry picked from commit 51949e50e0308c9ec41cd95bfe2be3d64e24802d) +--- + modules/sanity/sanity.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/modules/sanity/sanity.c b/modules/sanity/sanity.c +index 8140c07b2..581219001 100644 +--- a/modules/sanity/sanity.c ++++ b/modules/sanity/sanity.c +@@ -724,6 +724,7 @@ int check_proxy_require(struct sip_msg* _msg) { + * freed when the message freed. Lets hope nobody needs to access + * this header again later on */ + free_str_list(_msg->proxy_require->parsed); ++ _msg->proxy_require->parsed = NULL; + } + } + #ifdef EXTRA_DEBUG +-- +2.11.0 + diff --git a/debian/patches/upstream/0017-pua_reginfo-fix-memory-leak-when-usrloc-is-DB_ONLY.patch b/debian/patches/upstream/0017-pua_reginfo-fix-memory-leak-when-usrloc-is-DB_ONLY.patch new file mode 100644 index 000000000..5fc1e315b --- /dev/null +++ b/debian/patches/upstream/0017-pua_reginfo-fix-memory-leak-when-usrloc-is-DB_ONLY.patch @@ -0,0 +1,59 @@ +From 36814fafb02980e6165351e7cbe1acac0d11248d Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Thu, 16 Feb 2017 12:19:41 +0100 +Subject: [PATCH] pua_reginfo: fix memory leak when usrloc is DB_ONLY + +As release_urecord() clearly says: + +/*! + * \brief Release urecord previously obtained through get_urecord + * \warning Failing to calls this function after get_urecord will + * result in a memory leak when the DB_ONLY mode is used. When + * the records is later deleted, e.g. with delete_urecord, then + * its not necessary, as this function already releases the record. + * \param _r released record + */ + +(cherry picked from commit 1b0e1c3cbdd162fcd438a7d9bb412ddce73bc214) +--- + modules/pua_reginfo/notify.c | 2 +- + modules/pua_reginfo/usrloc_cb.c | 3 ++- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/modules/pua_reginfo/notify.c b/modules/pua_reginfo/notify.c +index 4bdd4caa8..51e27eb6e 100644 +--- a/modules/pua_reginfo/notify.c ++++ b/modules/pua_reginfo/notify.c +@@ -458,7 +458,7 @@ next_contact: + } + } + next_registration: +- // if (ul_record) ul.release_urecord(ul_record); ++ if (ul_record) ul.release_urecord(ul_record); + /* Unlock the domain for this AOR: */ + if (aor_key.len > 0) + ul.unlock_udomain(domain, &aor_key); +diff --git a/modules/pua_reginfo/usrloc_cb.c b/modules/pua_reginfo/usrloc_cb.c +index 7f84788ac..3e00a0eae 100644 +--- a/modules/pua_reginfo/usrloc_cb.c ++++ b/modules/pua_reginfo/usrloc_cb.c +@@ -223,7 +223,7 @@ void reginfo_usrloc_cb(ucontact_t* c, int type, void* param) { + publ_info_t publ; + str content_type; + udomain_t * domain; +- urecord_t * record; ++ urecord_t * record = NULL; + int res; + str uri = {NULL, 0}; + str user = {NULL, 0}; +@@ -332,6 +332,7 @@ error: + if(body->s) xmlFree(body->s); + pkg_free(body); + } ++ if(record) ul.release_urecord(record); + + return; + } +-- +2.11.0 + diff --git a/debian/patches/upstream/0018-usrloc-fix-ucontact-shared-leak.patch b/debian/patches/upstream/0018-usrloc-fix-ucontact-shared-leak.patch new file mode 100644 index 000000000..49473b056 --- /dev/null +++ b/debian/patches/upstream/0018-usrloc-fix-ucontact-shared-leak.patch @@ -0,0 +1,129 @@ +From 5b34d844c2cf6caba5888f26789c1472802fb0b8 Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Fri, 17 Feb 2017 13:25:31 +0100 +Subject: [PATCH] usrloc: fix ucontact shared leak + +keep a copy of urecord if mode is DB_ONLY as it is static +preventing leaking ucontact to shared memory + +Fix #1000 +See #997 for details + +(cherry picked from commit 819f9eae0066a94081b0805dadf69bd57050e4f0) +--- + modules/usrloc/ucontact.c | 13 +++++++++++-- + modules/usrloc/urecord.c | 35 ++++++++++++++++++++++++++++------- + 2 files changed, 39 insertions(+), 9 deletions(-) + +diff --git a/modules/usrloc/ucontact.c b/modules/usrloc/ucontact.c +index 68e03593f..ea0e8db1b 100644 +--- a/modules/usrloc/ucontact.c ++++ b/modules/usrloc/ucontact.c +@@ -1672,6 +1672,7 @@ static inline int update_contact_db(ucontact_t* _c) + */ + int update_ucontact(struct urecord* _r, ucontact_t* _c, ucontact_info_t* _ci) + { ++ struct urecord _ur; + /* we have to update memory in any case, but database directly + * only in db_mode 1 */ + if (mem_update_ucontact( _c, _ci) < 0) { +@@ -1680,6 +1681,8 @@ int update_ucontact(struct urecord* _r, ucontact_t* _c, ucontact_info_t* _ci) + } + + if (db_mode==DB_ONLY) { ++ /* urecord is static generate a copy for later */ ++ if (_r) memcpy(&_ur, _r, sizeof(struct urecord)); + if (update_contact_db(_c) < 0) return -1; + } + +@@ -1690,8 +1693,14 @@ int update_ucontact(struct urecord* _r, ucontact_t* _c, ucontact_info_t* _ci) + run_ul_callbacks( UL_CONTACT_UPDATE, _c); + } + +- if (_r && db_mode!=DB_ONLY) +- update_contact_pos( _r, _c); ++ if (_r) { ++ if (db_mode!=DB_ONLY) { ++ update_contact_pos( _r, _c); ++ } else { ++ /* urecord was static restore copy */ ++ memcpy(_r, &_ur, sizeof(struct urecord)); ++ } ++ } + + st_update_ucontact(_c); + +diff --git a/modules/usrloc/urecord.c b/modules/usrloc/urecord.c +index a6e7cec77..821821d02 100644 +--- a/modules/usrloc/urecord.c ++++ b/modules/usrloc/urecord.c +@@ -568,12 +568,16 @@ void release_urecord(urecord_t* _r) + int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci, + ucontact_t** _c) + { ++ struct urecord _ur; + if ( ((*_c)=mem_insert_ucontact(_r, _contact, _ci)) == 0) { + LM_ERR("failed to insert contact\n"); + return -1; + } + + if (db_mode==DB_ONLY) { ++ /* urecord is static generate a copy for later */ ++ memcpy(&_ur, _r, sizeof(struct urecord)); ++ + if (db_insert_ucontact(*_c) < 0) { + LM_ERR("failed to insert in database\n"); + return -1; +@@ -586,13 +590,19 @@ int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci, + run_ul_callbacks( UL_CONTACT_INSERT, *_c); + } + +- if (db_mode == WRITE_THROUGH) { +- if (db_insert_ucontact(*_c) < 0) { +- LM_ERR("failed to insert in database\n"); +- return -1; +- } else { +- (*_c)->state = CS_SYNC; +- } ++ switch (db_mode) { ++ case WRITE_THROUGH: ++ if (db_insert_ucontact(*_c) < 0) { ++ LM_ERR("failed to insert in database\n"); ++ return -1; ++ } else { ++ (*_c)->state = CS_SYNC; ++ } ++ break; ++ case DB_ONLY: ++ /* urecord was static restore copy */ ++ memcpy(_r, &_ur, sizeof(struct urecord)); ++ break; + } + + return 0; +@@ -608,11 +618,22 @@ int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci, + int delete_ucontact(urecord_t* _r, struct ucontact* _c) + { + int ret = 0; ++ struct urecord _ur; ++ ++ if (db_mode==DB_ONLY) { ++ /* urecord is static generate a copy for later */ ++ memcpy(&_ur, _r, sizeof(struct urecord)); ++ } + + if (exists_ulcb_type(UL_CONTACT_DELETE)) { + run_ul_callbacks( UL_CONTACT_DELETE, _c); + } + ++ if (db_mode==DB_ONLY) { ++ /* urecord was static restore copy */ ++ memcpy(_r, &_ur, sizeof(struct urecord)); ++ } ++ + if (st_delete_ucontact(_c) > 0) { + if (db_mode == WRITE_THROUGH || db_mode==DB_ONLY) { + if (db_delete_ucontact(_c) < 0) { +-- +2.11.0 + diff --git a/debian/patches/sipwise/presence-remove-transaction-creation-from-publ_notif.patch b/debian/patches/upstream/0019-presence-remove-transaction-creation-from-publ_notif.patch similarity index 95% rename from debian/patches/sipwise/presence-remove-transaction-creation-from-publ_notif.patch rename to debian/patches/upstream/0019-presence-remove-transaction-creation-from-publ_notif.patch index 50bee60bb..c4e4feaf0 100644 --- a/debian/patches/sipwise/presence-remove-transaction-creation-from-publ_notif.patch +++ b/debian/patches/upstream/0019-presence-remove-transaction-creation-from-publ_notif.patch @@ -1,12 +1,16 @@ -From eb980e6bc633a91751ceb9f3187587e52e383535 Mon Sep 17 00:00:00 2001 +From 4a41962b0389f37dbc4d905afd25e2cda5e7c39c Mon Sep 17 00:00:00 2001 From: Victor Seva -Date: Tue, 31 Jan 2017 18:46:11 +0100 +Date: Tue, 31 Jan 2017 19:23:53 +0100 Subject: [PATCH] presence: remove transaction creation from publ_notify_notifier() and mark_presentity_for_delete() * publ_notify_notifier() and mark_presentity_for_delete() are called inside a already created transaction * adding transaction handle for msg_presentity_clean() + +fix #960 + +(cherry picked from commit 6d157a4af708108b90a338614869de0ceeb94b68) --- modules/presence/notify.c | 24 ------------------------ modules/presence/presentity.c | 24 ------------------------