Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional jump or move depends on uninitialised value #878

Closed
qmphan opened this issue May 13, 2016 · 1 comment
Closed

Conditional jump or move depends on uninitialised value #878

qmphan opened this issue May 13, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@qmphan
Copy link

qmphan commented May 13, 2016

Running OpenSIPS 2.2 with Valgrind give me these errors:

==14639== Conditional jump or move depends on uninitialised value(s)
==14639== at 0x4A8ED4: qm_debug_frag (q_malloc.c:146)
==14639== by 0x4AA78E: qm_free (q_malloc.c:474)
==14639== by 0xBDE8E56: free_cell (h_table.c:192)
==14639== by 0xBE10E01: delete_cell (timer.c:239)
==14639== by 0xBE11714: wait_handler (timer.c:445)
==14639== by 0xBE1379B: timer_routine (timer.c:1069)
==14639== by 0x465759: handle_timer_job (timer.c:632)
==14639== by 0x5055DC: handle_io (net_udp.c:264)
==14639== by 0x503F1E: io_wait_loop_epoll (io_wait_loop.h:221)
==14639== by 0x5058BC: udp_rcv_loop (net_udp.c:308)
==14639== by 0x505E62: udp_start_processes (net_udp.c:372)
==14639== by 0x488BBC: main_loop (main.c:671)

==14636== Conditional jump or move depends on uninitialised value(s)
==14636== at 0x47C00B: str2ip (resolve.h:236)
==14636== by 0x481E18: sip_resolvehost (resolve.c:1759)
==14636== by 0xEB22212: nh_timer (nathelper.c:1402)
==14636== by 0x465759: handle_timer_job (timer.c:632)
==14636== by 0x5055DC: handle_io (net_udp.c:264)
==14636== by 0x503F1E: io_wait_loop_epoll (io_wait_loop.h:221)
==14636== by 0x5058BC: udp_rcv_loop (net_udp.c:308)
==14636== by 0x505E62: udp_start_processes (net_udp.c:372)
==14636== by 0x488BBC: main_loop (main.c:671)
==14636== by 0x48B5D1: main (main.c:1258)

==14636== Conditional jump or move depends on uninitialised value(s)
==14636== at 0x7A1C0F5: db_postgres_val2str (val.c:191)
==14636== by 0x4F460F: db_print_where (db_ut.c:347)
==14636== by 0x4EBEC3: db_do_update (db_query.c:376)
==14636== by 0x7A1B49E: db_postgres_update (dbase.c:596)
==14636== by 0xE2757FF: db_update_ucontact (ucontact.c:779)
==14636== by 0xE2760E6: update_ucontact (ucontact.c:947)
==14636== by 0xE49A599: update_contacts (save.c:647)
==14636== by 0xE49A9ED: add_contacts (save.c:700)
==14636== by 0xE49B35F: save_aux (save.c:846)
==14636== by 0xE49B527: save (save.c:893)
==14636== by 0x432D9B: do_action (action.c:1845)
==14636== by 0x42B1F7: run_action_list (action.c:172)

@liviuchircu liviuchircu added this to the 2.2.1 milestone May 18, 2016
@liviuchircu liviuchircu self-assigned this May 18, 2016
@liviuchircu
Copy link
Member

liviuchircu commented May 18, 2016

Thank you for taking the time to perform the Valgrind validations, @qmphan ! Here is some feedback:

  1. looks like a false positive. My guess is that it got lost in the list_entry macro (which obtains the struct cell * a timer link is part of), then everything went downhill from there:
#define list_entry(ptr, type, member) \
    ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
  1. Seems to be another false positive, since the memory of the next_hop is properly initialized in nh_timer, line 1386, before sip_resolvehost is called:
            memcpy(&next_hop, cp, sizeof(next_hop));
            cp = (char*)cp + sizeof(next_hop);
...
            he = sip_resolvehost(&next_hop.name, &next_hop.port,
                                 &next_hop.proto, 0, NULL);
...
  1. Looks like a real problem. I will follow-up with a commit.

liviuchircu added a commit that referenced this issue May 18, 2016
Reported by Minh Phan
Closes #878

(cherry picked from commit 38f525d)
jnewman02 added a commit to Vocalocity/opensips that referenced this issue Jul 30, 2016
* [acc] fix bugs in acc

* init all accounting methods data in mod_init as it was before;
cdr accounting initial data is loaded even if users don't use
CDRs but this shouldn't affect anything
* fix aaa bug - api was not loaded because it was badly included
in diameter define section
* fix event interface extra parameters - parsing extra parameters
for event interface was wrongly removed

* Make the s.int transformation more permissive

* Preserve sign on partially converted strings

* drouting api: Fix a double free bug

Crashes / memory corruptions could ensue after running "fraud_reload" MI
commands or during OpenSIPS shutdown, if fraud_detection had some data
to work with.

* [sipcapture hep] function to continue with the script after the hep route

* [sipcapture] update docs for new function

* clusterer: update README with a usage example

* clusterer: update html README layout

* TLS: Fix misleading error logs on accept() failures

OpenSIPS would always log SSL_accept() failures as being "rejected by
client". This is entirely not the case, as the errors may as very well be
server-side, due to cipher mismatches, failed peer verifications, etc.

Reported by Nabeel Shikder on the "users" mailing list

* Fixed bogus free of soring algorithms in DR.

* python: fix documentation links

* Update ws & tls modules documentation

* MYSQL DB migration updated.

SIP TRACE table changed, CALL CENTER tables added.

* Migrate cfg scripts to new acc interface.

* Fixed ilegal chars in XML

* Revert commit 1e1ea14

Do not automatically set db_url to the db_default_url as we have no idea if the default partition is gone be used. By forcing it we create some extra unwanted dependencies (like setting the version for the defaul table, even if not used).
Even if we break the backward compatibility, makes more sens to explicitly set the db_url if you use the default partition

* Revert commit d6cbbff

Do not automatically set db_url to the db_default_url as we have no idea if the default partition is gone be used. By forcing it we create some extra unwanted dependencies (like setting the version for the defaul table, even if not used).
Even if we break the backward compatibility, makes more sens to explicitly set the db_url if you use the default partition

* Fix bogus log

(cherry picked from commit 87c93b8)

* README files regenerated

* Fix extended Call-ID in B2B

The old CallID format did not ensure unicity across time, so we include now time info into the callid.
Closes  OpenSIPS#783 .

* Update CREDITS and AUTHORS

* Makefile: always put the minor in name

Even if it is redundant

* For beta release, enable malloc debugging

* Makefile: increase version to 2.3.0-dev

* Improve the AUTHORS file

* Various doc improvements

* [db_sqlite] use DB_STRING type when the column value type is DB_STRING

* Fix missing logs if debug_mode after log_stderror

* [db_sqlite] add explanation about implementation

* [dialog] repl_prof_add never increments the return buffer size for threshold comparison

* [siptrace][traceID]fix mysql uri parsing

* Fixed checking return code for pre raw callbacks

If the TH pre raw callbacks fails, it may return a NULL buffer, leading to a later crash when we want to parse the SIP message.

(cherry picked from commit 4be2662)

* [drouting] pvar for matched partition if wildcard operator used

* [drouting] check if partition pvar is writable

* [drouting] docs updated for partition id variable

* Fix typo in README example

* Fix missing GPL headers for mem files

* cachedb_redis: Prevent crash when re-connect keeps failing

* Fix a PKG leak in the SIP message processing stack

Commit 7464a86ec introduced a processing context leak during the
handling of basically any SIP request in all protocol stacks
except for HEP.

Reported by Trevor Francis <trevor@46labs.com>

* Allow negative values for "memdump" and "memlog"

They should behave just as "log_level" does.

* pi_http: return "200 OK" instead of "0 Unknown"

* Suppress "no free TCP receiver" logging noise

This was added long before async TCP support, and it is now
only useful to developers.

* [acc] fix double free issue

Since callbacks were registered only at first, and aftewards only
flags were changed there was no way to know if tm is to free the
shmed flags from acc or dialog. For this a new flag was introduced
to indicate whether the flags shall be removed either by dialog or
tm.

* [acc][bugfix] register tm free function only once

* dialog: Remove a chunk of dead code

*  [sipcapture][HOMERv5 incompatibility fix] HOMERv5 table rotation aware logic

    * HOMVERv5 allows rotating tables by having a prefix which is
    the fixed table name and a suffix which is a string containig
    timestamps
    * sip_capture now accepts table name as a parameter to sip_capture()
    function
    * both global table name and sip_capture table_name can have
    a prefix(string) and a suffix(strftime format string);
    * fixed bugs in async query building

* [sipcapture][HOMERv5 incompatibility fix]generic capturing function

      Added new function called report_capture which allows
capturing hep packets in a generic format. It will be very
effective for the third version of the hep protocol for capturing
packets other than SIP. Also added a new table called rtcp_capture
for storing everything capture with report capture.

* [sipcapture][HOMERv5 incompatibility fix] updated docs for report_capture and new table name format

* Fix typo in do_accounting() naming is cfg templates

* Fixed bogus pkg_free on pointer in data segment

Reported by @dzhou121
Closes OpenSIPS#854

(cherry picked from commit b9aa873)

* MI library: Add comments regarding a known issue

Currently, MI arrays cannot contain objects with non-identical
"name" attributes.

This patch also quickfixes this issue in mi_list_all_profiles() by dropping
the array idea altogether, in favour of a top-most object.

* [tm]fix context functions header

* [context][bugfix] each context has its own destroy functions vector

Credits to Razvan Crainea

* [siptrace][bugfix] sequential requests - set context for sl callbacks

* [proto_hep][bugfix] check memory allocation

* tls_list() may be called even without DB support

Avoid locking if DB support was not enabled.

* exclude proto_wss, use QM_MALLOC

(cherry picked from commit b7ac4fc)

* Fixed default FIFO file name

* Fixed MI nodes in 'sip_trace' command.

Formatting chars must not be included in the MI tree

* [acc][bugfix] correctly store do_accounting() flags

	Flags are now moved from processing context into
transaction context when the transaction is created, this way
having visibility for the whole transaction.

* [proto_hep][bugfix] fix bad sip payload size calculation

* [sipcapture] remove time-consuming unnecessary chunk of code

* [sipcapture] fix incompatibilities with HOMERv5 db schema

* [siptrace][bugfix] avoid double free on cancelled transaction

* [tls_mgm] properly handle SSL_ERROR_SYSCALL on SSL_shutdown

* memory hash summary: Fix a fragment counting bug

When debugging memory, a very small number of memory fragments would
be counted twice, leading to a slightly incorrect overall report
(almost unnoticeable)

* memory hash summary: Fix a rare memory leak

Proper cleanup upon running into a "no more system memory" state while
performing the fragment summary of the entire memory hash.

* Fixed arrays in clusterer_list MI command

* Fixed wrong MI tree in clusterer_list (related to previous commit)

* Avoid space in MI node name

(cherry picked from commit 5c8869b)

* Enable debug_mode settings only if debug_mode gets set to enable.

* [hep][bugfix] correctly store ports/addresses

* Revert "[hep][bugfix] correctly store ports/addresses"

This reverts commit 7b1359a.

* [proto_hep][bugfix] use the correct port when unpacking

* [siptrace][bugfix] use the correct sockaddr structure for storing

* allow a module to register multiple protocols

* mathops: fill in entire structure

* [drouting] bug fix and memory leak fix

* free gateways list for each carrier at reload
* use map_find instead of map_get to search an element in the tree

* [hep] multiple versions/protocols can be used in the same time

Since commit 0873c14 multiple
network protocols can be used from one module. Proto_hep was changed
to be able to use both tcp and udp in the same time. Moreover, there
is no hep_version needed since we can receive HEPv1,v2 and v3 on any
UDP interface. Since HEPv1 and v2 are not compatible with TCP, only
HEPv3 will be support. For HEPv3, Sipcapture module can now relay
packets from TCP to UDP or the reverse way.
Siptrace module was also improved. Trace id's can now be defined with
hep version and transport protocol, in order to be able to do multiple
types of tracing with different HEP protocols and/or network transports.

* [hep] updated docs for previos commit

* [proto_hep] correctly name function

* do not overwrite permissions of config file when re-installing

* Allow PREFIX overwrite

* [sipcapture] new HEPVERSION script variable

* [sipcapture] updated docs for HEPVERSION

* proto_bin: remove debug INFO message

* [acc][bugfix] fix memory leak

* fix leak caused by missed calls - receiving a negative reply
caused flags not being freed

* regex: fix spell-check in package

* Updated opensipsctl.base to also search /sbin

The md5 utility is located at /sbin/md5 on FreeBSD 8.3. An additional common location was added to allow the script to accommodate this.

* dialog and usrloc: broadcast replication data all time

This prevents clusterer module from marking a node as not reachable when there
is no traffic at all.

Fixes OpenSIPS#849

* debian: add missing dependency

Ovewrite lintian warning

(cherry picked from commit 83a23be)

* Makefile.conf: add deps for tls_mgm and proto_wss

This prevents 'make menuconf' from deleting these modules from the generated
configuration file

* ratelimit: initialize the length of the algorithm

* [sipcapture] be able to set proto_type in report capture function

* [sipcapture] fix bad conditions

* [sipcapture][bugfix] invalid memory access

* [sipcapture][bugfix] invalid static vector size calculation

* [siptrace][bugfix] fix trace_id parsing

* pv_printf() - Some code refactoring

Code is more reusable, and will lead to smaller number of LoC, less duplication
and fewer inconsistencies.

* [sipcapture][bugfix] fix bad string hex value parsing

* [sipcapture] fix new hep proto names string

* [sipcapture] allow any hep version for hep_net variable

* [siptrace] fix hash calculus for extended hep trace_id

* radcli support and radius library autodection from makefile
* aaa_radius module can be compiled with radcli library
* Makefile will autodetect the radius library to compile with; the
order is radcli-->freeradius-->radiusclient-ng if more radius
libraries are installed
* new Makefile rule "print_radius_lib"
* if custom library is to be used compile with
RADIUSCLIENT=RADCLI/FREERADIUS/RADIUSCLIENT

* [aaa_radius] implement missing function from radcli

	Functions like rc_get_ipaddr are removed from radcli
since they are only compatible with IPv4. Since aaa_radius
implementation is based on this function it had to be rewritten
in our module.

* event_flatstore doc: Fix some typos

* event_virtual doc: Fix grammar/typos

* proto_sctp: Fix startup bug caused by a typo

* [siptrace][bugfix] bad structre used when printing HEP trace_id via mi

* [sipcapture] fix sip_capture table schema

* [nathelper] fix bad logic regarding the timer list

* event_flatstore: Remove unncessary startup warning

* event_flatstore: Fix a memory management bug

* [dispatcher] fix double allocation issue

* [mi_json] return code rework for errors

	Mi_json now returns only 200 OK as HTTP code. We have two
records for inspecting mi level errors, "code" for the error code
and "reason" for the error message.

* [mi_json] remove double inverted commas for internal error messages

* [sipcapture] fix bad time calculation

* [sipcapture] fix possible data type loss

* Fixed bogus memory operations.

Fixed bogus free (of uninit pointer) if parse_contact() fails
Fixed shm leak on errors after print_rr_body
Fixed shm leak on success if record_route is present.
Reported by John Nash.

(cherry picked from commit 4b0fca5)

* nathelper: ping WSS clients when using natping_tcp

See ticket OpenSIPS#875

* [mi_json] return jsonrpc compliat error message

* usrloc: Fix some uninitialized memory issues

Reported by Minh Phan
Closes OpenSIPS#878

* [mi_json] minor fixes in mi_json

* [mi_xmlrpc] return code rework for errors

Mi_xmlrpc_ng now returns only 200 OK as HTTP code. We have two
labels for inspecting mi level faults, "code" for the error code
and "message" for the error message. Check
http://www.tutorialspoint.com/xml-rpc/xml_rpc_fault.htm for
more details.

* Fixed preserving 3xx Contacts in TH without dialog

Reported by Pete Kelly.
Closes OpenSIPS#656.

* [dispatcher] multiple fixes

* use pkg memory instead of shm for fixup variables
* fix int list building - avoid building a circular list

* Fix bogus timer ref counter during expire update.

Many thanks to Trevor Francis for reporting and helping with troubleshooting and testing.

* event_route: Fix compilation warning

* [Makefile] make json path editable

* Process sequential messages received in CONFIRMED_NA state

Due to UDP race conditions, sequential messages may be received
before the ACK confirming the initial INVITE ( eg. Re-INVITE sent
immediately as the call is established in order to force
a specific codec ) - also push these requests through the whole
dialog processing in order to avoid any future issues ( eg. CSEQ
updating which, if left unprocessed, will lead to generating out
of order sequentials by OpenSIPS )

* Fix a string concatenation operator bug

This patch fixes an issue with string concatenation where any NULL
operand would cause all operands to its left to be ignored when
computing the result of the expression.

Reported by Ovidiu Sas
Closes OpenSIPS#870

* clusterer: Fix bad doc example

Reported by "alias_neo" on IRC

* re-register topo hiding callbacks after restart

Thanks to Pete Kelly for reporting this

* th: fix dlg flag check

* Fix invalid memory access with async MySQL queries

Due to the way the libmysqlclient query result strings were managed,
they would be freed by the library before OpenSIPS would copy them
into the output AVPs.

This patch fixes the issue by adding a new DB API function which handles
the cleanup of async query results.

Reported by Ovidiu Sas
Addresses issue OpenSIPS#873

* provide a way to specifi opensipsctlrc

Add a new variable that can specify what opensipsctlrc file to use for the
opensipsctl and opensipsdbctl tools

* Added extra log message on openssl 1.0.1e-fips bug.

If CRYPTO_set_mem_functions() fails, make a note on the openssl 1.0.1e-fips bug, so users may have a hint on the actual issue.
See more  OpenSIPS#834.
Closes  OpenSIPS#834.

(cherry picked from commit c5bb0d0)

* Fix potential 100 Trying duplicates.

Added the "auto_100trying" module parameter to allow the script writter to take control (from script level) over when the 100 Trying reply is to be sent back.
By default, the reply is automatically generated when the INVITE transaction is created.
Fixes OpenSIPS#833

* [mmgeoip] allow chosing memory caching type

	Before GEOIP_MMAP_CACHE was used causing a segmentation
fault when database file was changed. Now users can choose between
reading the database directly from file, cahing it into memory with
the possibility to change the database file at runtime.

* Revert "Accept TCP aliases by default"

This reverts commit d62bc96.

Firstly, TCP connection reusage (RFC 5923) should only be employed between
TLS endpoints - only TLS allows the endpoints to authenticate each other
during connection setup, preventing unauthorized connection hijacking.

Secondly, aside from any security considerations, RFC 5923 must
not be employed fanatically (Proxy-Proxy, Edge-UA, UA-Proxy) on any TCP
connection (especially disregarding the ";alias" Via parameter!), but
rather only between adjacent SIP entities who can both initiate a
connection towards each other, and also support the RFC. In the real
world, we're basically only talking about the Proxy-Proxy usage case, as
any SIP UA scenario will most likely involve some form of NAT and a
Proxy that cannot open connections backwards, towards the UA. In these
cases, TCP connection reusage is _completely_ out of the question, as a
single UA might end up receiving all calls of all users behind their
public IP.

Thanks to Jonas Borjesson for reporting the problem in the first place.

* TCP connection lookup: Add matching by transport

The fact that all currently supported TCP-oriented protocols have different
standard ports is not an excuse for not including the transport into the
match condition (i.e. dest IP address + dest port + dest transport).

This may very well prevent issues with messages being sent out over the
wrong TCP connection in a number of scenarios where we employ TCP connection
reusage over both plain TCP and TLS with a Proxy that specifies the same port
in the topmost Via header when it establishes each of the two connections.

* TCP alias lookup: Add matching by transport

Further improving commit 13970bb.

* MI node creation: Add some useful function comments

* mi_xmlrpc_ng: Fix a shared memory leak

* mi_xmlrpc_ng: Fix NULL pointer dereference

Any MI tree with a topmost Array structure would have caused a crash

* mi_xmlrpc_ng: Remove an incorrect free operation

Completes commit d047e10

* Fixed typo

* Obey USE_SYSV_SEM and USE_PTHREAD_MUTEX.

If USE_SYSV_SEM or USE_PTHREAD_MUTEX are defined via Makefile.conf, do you force autodetection (based on arch type) of the locking support.

* Fix bogus destroy of a RW lock.

* Proper support for USE_POSIX_SEM option in Makefile

* Fix bogus set locking functions.

It is used for SYSTEM V locking only, looks like a copy'n'paste error.

* call_center: obey lock_set interface

* Fix warning in SYSTEM V locking functions

* Added some comment

* acc: Remove deprecated modparam dependency

* Update makefile to support gcc 6.1

Fix gcc 6.1 warnings

* acc: properly detect parsing errors

* dialplan: Fix a rule tie-breaking bug

When an input string would match both a "string" rule and a "regex"
rule, the priority based tie-breaking was incorrect (now favouring
the bigger priority instead - opposite to default module behavior).

Thanks to @paolodepa for suggesting this fix
Fixes issue OpenSIPS#696

* dialplan: Improve documentation

Added paragraphs regarding rule types along with explanations on
they way priorities and rule tie-breaking work.

* dbtext: convert DBG to ERR for better debugging

* clusterer: proper translation to bigint for dbtext

This creates the proper type for bigint in the clusterer table for dbtext

Thanks go to Trevor Francis from 46Labs for reporting this
Close OpenSIPS#699

* Improve error reporting for unknown script vars

Fixes OpenSIPS#574

* Fixed missing MI reply on pua_publish.

Properly send an MI reply for the async pua_publish with Expires 0.
Many thanks to Damien Sandrs for invetigating and reporting.

Closing OpenSIPS#657

* add license to rw_locking.h header

* Link the dialog cell into internally generated requests from the dialog module

Fixes OpenSIPS#839

* [acc] fix double free issue for multiple dlg callbacks

	The last byte in acc flag mask now holds a ref counter in
the last byte. The counter is increased each time a dialog callback
is invoked, and decreased for each free function corresponding to
a callback. When the ref counter reaches 0, flags can be freed.
The atomicity of the ref counter is based on the fact that
dialog callbacks and their free functions are called sequentially,
one after the other.
ACC_DIALOG_CONTEXT and ACC_CDR_REGISTERED flags where moved in the
7th byte of the flags.

* Fixed proper cleanup on failure of tcpconn_new()

The chances for going for error cases are very low, still let's do it in the proper way

* If POSIX sems are used, be sure to link against pthread lib

* Fixed interface matching in loose_route()

If port is missing in Route URI, do not assume default 5060, but consider the schema and protocol (they may require a different default port).
Ex: sip:10.0.0.5;transport=tls was previously handled as sip:10.0.0.5:5060;transport=tls, which is wrong as the default TLS port is 5061
Reported on mailing list by Ravitez Dondeti.

* Fix documentation on former b2bl_key_avp module param

* load_balancer: Fix a possible crash

Could have led to a segfault when OpenSIPS would run oom

Reported by Qasim Khan

* Proper handle the case of no usrloc domain registered.

Prevent get_next_udomain() crashing if there are no usrloc domains registered (reported by Qasim Akhan on users mailing list.
Do not enable the pinging support in nathelper if usrloc has no registered domains.

(cherry picked from commit 8f0c677)

* Fix error handling in DB writes.

If inserting/updating a dlg record in DB fails, do not exit with error, but continue with the rest of the dialogs.
Credits for finding and reporting this go to Rik Broers @ Motto

* Removed unused "error" jump label

* Removed wrong "NOT NULL" constraint over the contact DB fields

The code actually handles the case of NULL callee / caller contacts, so DB must allow NULL values.

* Removed compilation warning

implicit declaration of function â"sched_yield" [-Wimplicit-function-declaration]

(cherry picked from commit 8ef8d79)

* [mi_xmlrpc_ng] fix fault incompatibilities with xmlrpc standard

* Consider WSS also a SIPS protocol

Reported by Varghese Paul ( @varghesepaul )
Closing OpenSIPS#899.

* Fix evaluating the SIP port from a SIP URI.

Use the new function get_uri_port() to evaluate the port and proto, in a SIP wise manner, form a SIP URI. If port/proto are not explicitly set in the URI, consider the default port for the used transpor proto. If protocol misses, we assume the default protos according to the URI schema.

NOTE: it is completly bogus (and dangerous) to assue 5061 if SIPS schema is used as:
1) SIPS can use used with WSS, which actually has 443 port
2) TLS can pe required via transport param in a SIP schema URI too

* Fixed typo in comment.

* Fixed migration of Call Center tables

Reported by John Quick.

(cherry picked from commit d090114)

* Fixed forcing FAST LOCKS for arm6.

Use FAST locking support for arm6 too.
For Linux, use POSIX as default locking support.

* Fix docs on missing module dependency.

If replicate_contacts_to parameter is turned on, usrloc depends on the clusterer module.
Credits go to Sammy on mailing list.

* [acc][bugfix] enable acc flags refcount only after dlg callbacks called

* Fix memory corruption on $stat() vars

The $stat() var specs are kept in pkg, while the name (if stat not found) is kept in memeory. This means all the copies (form all procs) of the specs will point to a single shm block. It is not safet to free this block as you have no idea how many copies of the spec (from other processes) still refer the name.
Closes OpenSIPS#902

(cherry picked from commit 4baead7)

* Fixed failure to enable NAT pinging.

Commit 8f0c677 introduces a bug in testing is usrloc domains are available, and if not, to disable the NAT pinging in nathelper. The test is wrong as it is done in mod_init, while registrar module registerd the usrloc domain via fixup function, after the mod_init section.

Reported by Nick Altmann

* Add support for SIP URIs without user part in 'avpops' module.

This module provides a set of avp_db_xxx functions which take pseudo
var and flag as first argument. Flag can be one of username, domain,
uri or uuid. Previosly avp_db_xxx functions used to return an error if
flag has been set to username, domain or uri and specifed pseudo var
did not contain username and host after parsing as SIP URI. This
behaviour seems to be strange because if flag is being set to
domain/username and sip URI contains domain/username we can still
load/store/delete this variable.

(cherry picked from commit 459f2e9)

* dispatcher: round robin uses weights to select destination

* dispatcher: updated documentation for round-robin change

* usrloc User-Agent filtering: Fix memory corruption

The "ua_re_check" macro added by commit e5cb980 is broken in several ways:
    * unsafe read operation on shared memory
    * unsafe write operation on shared memory
    * incorrectly handled error case, without restoring the backup byte

This patch corrects the above issues by extending the user_agent buffer.

* Update rtpproxy.c

When building I/O vector for command to rtpproxy in "force_rtp_proxy_body", after an IPv6 address is detected and the "6" option is added, increase the length component in the I/O vector so it is passed correctly.

* Update rtpproxy.c

When moving stored parameters from Branch AVP to Dialog variable, make sure that the integer value "setid" is handled correctly so that it remains valid for the remainder of the dialog.

* rtpproxy: no need to update the len for IPv6

* Fix proper testing of context content

If a STR is register to the context, a valid STR * will be always returned , so we need to test the content, not the pointer.

(cherry picked from commit 968a8a8)

* [sqlite][bugfix] free column names when freeing the result

* init: use the specified CFGFILE in debian init

In case the CFGFILE changes in the init script, opensips will still start with
the compiled file instead of the one configured

* proto: always populate default values for protocols name and port

This allows you to print the protocol you received, and its associated port

* Fix wrong number of columns when preloading via a DB backend without Fetch support.

* Allow proto modules to populate its name

* Fix script varibles for providing port and proto (as part of SIP URI).

If the SIP URI does not have an explicit port or proto, determine the default port/proto in a SIP wise manner (rather than returning 5060 / UDP) (Ex: sip:example.com;transport=tls has default port 5061 and not 5060 ; or sips:example.com has default proto TLS and not UDP).

Affected variables are $dp, $rp, $op and $dP, $rP, $oP

* Fix dialplan module when using db_text backend.

The db_text makes no difference between NULL or "empty string" values in DB -> both are internally translated as NULL . The dialplan module, in a very abusive way, forces "not null" (in DB schema and in the code for data validation) even for columns that are optional (like subst_exp, repl_exp, timerec and attrs). Besides being bogus (if a column is not to be used, you have to set it to empty string rather than let it NULL), it makes impossible the usage of db_text with dialplan.
This fix allows (DB and code) the mentioned DB columns to be also NULL.
The change is backward compatible, it should not break any existing usage of the dialplan module.

(cherry picked from commit 8f54897)

* Refactor commit 58a944c

* Fix compiler warning

Using gcc 4.8.4, we would get:

net/trans.c:43:2: warning: missing initializer for field ‘name’ of
‘struct proto_info’ [-Wmissing-field-initializers]
  { }, /* PROTO_NONE */
    ^

* [siptrace][bugfix] fix bad macro in siptrace(trace local ip logic)

This commit closes OpenSIPS#916
Thanks to @Tinet-AaronAn for reporting the issue

* usrloc: Fix an operator precedence bug

Introduced in commit 03398fb. Oops!

* module statistics: Properly update the "real_used" memory stat

* Merge pull request OpenSIPS#919 from Danfx/2.2

Fix memory leak: after sqlite prepare was deleted stmt compiled, free…
(cherry picked from commit 308ff0d)

Conflicts:
	modules/db_sqlite/row.c

* [sqlite] fix warning

* permissions: fix get_source_group() return

In case a group is not found, return -1 instead of true

* acc: Fix incorrect Request-URI handling

If the config script does not include any Request-URI altering logic
(e.g. no lookup() or $ru manipulation), the acc module would incorrectly fill
in a "msg->new_uri" field which should NOT be freed into the SIP request
structure, leading to the memory pool being corrupted upon transaction release.

Credits to Guillaume Lacroix for reporting

* fix core database engine bug introduced with commit 980f15e

* [db_sqlite] fix memory management bugs

* core free function was used to free starting with commit 980f15e
which was not freeing the memory correctly(result rows were
allocated all at once, but in the current version they were freed
once at a time);
* check if memory is allocated to prevent core dumps;

* [db_sqlite] remove unnecessary file introduced in commit 5936274

* Fix socket selection for outbound UDP.

Do not use the bind_address of the process when comes to send an UDP package (bind_address may be different from process to process, so the selection may give different results, depending on the processes sending the UDP).
If you have a sip_msg, try using received interface of the msg (if matches), otherwise use the first UDP interface.

* Fixed compiling on arm6 with fastlocks

Partial revert of 058e16 as we need some extra asm code for fast locking on arm6.
See OpenSIPS#923
Closes OpenSIPS#912

* Fix error and warnings for compile flag USE_SHM_MEM

Fixes OpenSIPS#905

* Fix error message when a route is not defined.

Print the name of the route too - the ID is irrelevant for the script writter.

* dialog: advance to next cell in case of error

* [acc][bugfix] check if database loaded before using its handler

* Fix compiling warn on missing return

* Fix building Via Branch in stateless mode

Instead of copying the branch value from a previous statefull Via header (which may lead to overflow as OpenSIPS has a maximum value for the built branch), we generate a new branch value based on the previous Via branch - in this way, we have full controll over the length of the resulting Branch and we also inherit the uniqueness of the branch value (from the prev Via hdr).

Reported by Gupta, Rahul and Elliott, Ray

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

* Fix advertised port and address per branch.

Before the advertised_port/address are preserved only in the UAS part of the transaction - that means it is only one value and it is from the setting done in Request Route; whatever later setting done in Failure Route or Branch Route are not preserved at transaction level (even if they are used on the spot, for sending out the INVITE).
So, when we have to build a local request (ACK or CANCEL), we do not remember which specific address/port were advertised for that particular UAC (branch).

Fixes OpenSIPS#917.

* add debian packaging for proto_wss, proto_tls and tls_mgm

Reported by Rik Broers
Close OpenSIPS#931

(cherry picked from commit b40035e)

* rest_client: Fix incorrect trim operation

* permissions: allow any supported protocol

Before this commit, the protocol check was hardcoded in the module. This
commit allows to add in the permissions table any transport protocol
supported.

Thanks go to Kirill Galinurov for reporting this!

* Fixed memory leak on modules/drouting/drouting.c

This leak occures in function get_group_id() when do_routing is called without parameters in opensips.cfg.
In this case the dr_default_grp variable is not equal -1 and 'return dr_default_grp' is executed without freeing the res variable previously allocated for query execution.

* Remove unnecessary test.

"res" cannot be null at that point

* Extended the callback in dialog module.

1) avoid deadlock if from a dialog callback run under the lock (like DLG_SAVED) you use dialog functions (via API) to add dlg vals or set profiles.
2) renamed DLG_SAVED into DLG_DB_SAVED
3) added new DLGCB_DB_WRITE_VP callback that is triggered (while dialog is locked) just before flushing the vals/profiles into DB - this will allow other modules to quickly insert / update dlg vals just before the DB flush (to take advantage of the dlg persistency, while handling dynamic values). <- this is required by some ongoing work in ACC module.

* 	[acc] introducing new extra/leg engine; module redesign

	Redesigning accounting module extra values engine raised
    new problems which in the end were solved by redesigning the
    whole accounting module.
        First of all an accounting module context was created
    which is available for the whole dialog lifetime. Having
    this mechanism all values that were stored in avps or dialog
    values are now being held in this context.
        Using the new dialog callback that is triggered at shutdown,
    extra and leg values are not abusing anymore of dialog values.
    We store them there only when OpenSIPS closes by any means. This
    made the code look a lot cleaner and the program faster by not
    creating a dialog value for all INVITEs and restoring it for each
    BYE.
        Accounting module extra values new engine are the main purpose
    of this commit. There are only two variables now, called
    $acc_extra and $acc_leg. They are visible during the whole lifetime
    of a dialog and provide a much cleaner and easier way to use this
    powerful engine.
        New parameters have been defined, extra_fields and leg_fields
    through which one can define tags and log values. The tags are
    used to reference $acc_extra and $acc_leg variables, whereas the
    leg_fields will be the value that you will see in the logs.
        As concerning the acc_leg variable, new legs can be created
    using acc_new_leg() function. The value of the current leg can
    be retrieved using $acc_current_leg. It's the script writer the
    one who has to decide when is the moment to jump to a new leg.
        Also from this commit diameter support from acc module has been
    removed. Diameter didn't have any support and it wasn't
    compatible with a diameter server.

* [acc] updated docs for previous commit

* [acc] fix bad condition when fetching context from dialog

* Added support for internal async I/Os

Module care register FDs to the reactor in order to be triggered when data is available (and run a handler).

* Better naming for the async script related functions

* Fix handling async in sync mode upon failure

* tm: Fix loader error
jnewman02 added a commit to Vocalocity/opensips that referenced this issue Jul 30, 2016
* Fixed some overlapping defines

* [nathelper] fix bad condintion for branch checking

* [siptrace]docfix - default trace_on param value

* Preserve 3xx contacts via TH

Do not change the contacts in 3xx replies to initial INVITE, as this breaks SIP redirect.
Reported by @petekelly
Issue OpenSIPS#656

* Proper handling of isolated EPOLLHUP events.

capture and handle EPOLLHUP or EPOLLERR events even if they are not in conjunction with EPOLLIN or EPOLLOUT.
Many thanks to @santhosh-kumar for reporting and helping with troubleshooting.

Fix for OpenSIPS#829

* Makefile.defs: new CC_OPTIMIZE_FLAG to define the compiler optimization level

* Makefile.defs: disable optimizations while debugging (DBG_MALLOC is set)

* [acc]flags used for accounting now replaced by do_accounting()

Introducing new do_accounting() function. It has 3 arguments,
first one is used to specify the type of accounting separated
by '|'(db, log, aaa, evi, diam), second one to specify the flags
used for accounting also separated by '|' (cdr, missed, failed -
failed_transaction_flag) and the third parameter represents the
name of the table used for accounting.

* [acc] updated docs for do_accounting()

* [sipcapture] special route for hep messages

hep_store_no_script parameter now changed into hep_route. Using
this parameter one can either do sip_capture() without going
through the script or define a route where messages can be
forwarded using hep_relay() function and modified if hep version
3 is used, withot parsing the sip message, or go through the
main request route as usual where the message will be parsed.
For the second version, the hep route, sip_capture() won't be
available since the message it's not parsed. This functionality
stands only for routing/modifying the message.

* [sipcapture] updated docs for hep_route parameter

* [sipcapture] Allow module starting without db url if db not used

* Improve logging when using "memlog"

    * blocks are more readable now (pkg vs. shm)
    * malloc vs. free vs. realloc operations are more distiguishable

* Improve robustness of core URI copying functions

Namely set_ruri(), set_dst_uri(), set_path_vector().

This patch corrects the behaviour of the above functions when they are
fed strange/corrupt strings, such as {NULL, 5} or {0x7fb..., 0}.

There are still plenty of pieces of OpenSIPS code which assume such
strings should be correctly processed, e.g. next_branches(), which may
lead to a whole world of problems ranging from segfaults, double free
operations and dangling pointers all the way up to intermixed shm/pkg
memory pointers.

The best way of addressing this issue is to simply accept such input and
zeroize (and free) the concerned sip_msg attributes.

Many thanks to Ovidiu Sas <osas@voipembedded.com> for in-depth error
reporting and assistance in fixing this issue

* F_MALLOC: Allow free(NULL) when debugging memory

* [sipcapture]fix dummy request building

* Updated the ACC documentation

* clusterer: Various coding style improvements

    * clean loops
    * shorter boolean test operators
    * avoid redundant global initializations
    * improve variable naming
    * fix bad log messages

* [acc]cancel_accounting function for acc

This function allows unsetting parameters set by do accounting
function. It has the same parameters excepting the table name.

* [acc]updated docs for cancel_accounting()

* [acc]change cancel_accounting() name to drop_accounting()

* [acc]fix docs for drop_accounting()

* sql_cacher: Add module dependencies

It should be loaded somewhere after all SQL and NoSQL drivers

* [acc]fix event registration issue

* Fix function name in docs

* Fixed function name in export.

* [acc] fix bugs in acc

* init all accounting methods data in mod_init as it was before;
cdr accounting initial data is loaded even if users don't use
CDRs but this shouldn't affect anything
* fix aaa bug - api was not loaded because it was badly included
in diameter define section
* fix event interface extra parameters - parsing extra parameters
for event interface was wrongly removed

* Make the s.int transformation more permissive

* Preserve sign on partially converted strings

* drouting api: Fix a double free bug

Crashes / memory corruptions could ensue after running "fraud_reload" MI
commands or during OpenSIPS shutdown, if fraud_detection had some data
to work with.

* [sipcapture hep] function to continue with the script after the hep route

* [sipcapture] update docs for new function

* clusterer: update README with a usage example

* clusterer: update html README layout

* TLS: Fix misleading error logs on accept() failures

OpenSIPS would always log SSL_accept() failures as being "rejected by
client". This is entirely not the case, as the errors may as very well be
server-side, due to cipher mismatches, failed peer verifications, etc.

Reported by Nabeel Shikder on the "users" mailing list

* Fixed bogus free of soring algorithms in DR.

* python: fix documentation links

* Update ws & tls modules documentation

* MYSQL DB migration updated.

SIP TRACE table changed, CALL CENTER tables added.

* Migrate cfg scripts to new acc interface.

* Fixed ilegal chars in XML

* Revert commit 1e1ea14

Do not automatically set db_url to the db_default_url as we have no idea if the default partition is gone be used. By forcing it we create some extra unwanted dependencies (like setting the version for the defaul table, even if not used).
Even if we break the backward compatibility, makes more sens to explicitly set the db_url if you use the default partition

* Revert commit d6cbbff

Do not automatically set db_url to the db_default_url as we have no idea if the default partition is gone be used. By forcing it we create some extra unwanted dependencies (like setting the version for the defaul table, even if not used).
Even if we break the backward compatibility, makes more sens to explicitly set the db_url if you use the default partition

* Fix bogus log

(cherry picked from commit 87c93b8)

* README files regenerated

* Fix extended Call-ID in B2B

The old CallID format did not ensure unicity across time, so we include now time info into the callid.
Closes  OpenSIPS#783 .

* Update CREDITS and AUTHORS

* Makefile: always put the minor in name

Even if it is redundant

* For beta release, enable malloc debugging

* Update version to beta

* Improve the AUTHORS file

(cherry picked from commit 32d0e1a)

* Update ChangeLog

* Update opensipsdbctl for 2.2

* Various doc improvements

(cherry picked from commit d932652)

Conflicts:
	scripts/opensipsdbctl
	scripts/opensipsdbctl.base

* Fix missing logs if debug_mode after log_stderror

(cherry picked from commit 29182c9)

* [dialog] repl_prof_add never increments the return buffer size for threshold comparison

(cherry picked from commit 52028bd)

* Fixed checking return code for pre raw callbacks

If the TH pre raw callbacks fails, it may return a NULL buffer, leading to a later crash when we want to parse the SIP message.

* [drouting] pvar for matched partition if wildcard operator used

fix missing functionality - return to script the matching partition

(cherry picked from commit 7551c66)

* [drouting] check if partition pvar is writable

(cherry picked from commit cf0945c)

* [drouting] docs updated for partition id variable

(cherry picked from commit 2013276)

* Fix typo in README example

(cherry picked from commit 983ad95)

* Fix missing GPL headers for mem files

(cherry picked from commit 8ffd592)

* cachedb_redis: Prevent crash when re-connect keeps failing

(cherry picked from commit b501df7)

* pi_http: return "200 OK" instead of "0 Unknown"

(cherry picked from commit 73f8117)

* Suppress "no free TCP receiver" logging noise

This was added long before async TCP support, and it is now
only useful to developers.

(cherry picked from commit 142e7e0)

* [acc] fix double free issue

Since callbacks were registered only at first, and aftewards only
flags were changed there was no way to know if tm is to free the
shmed flags from acc or dialog. For this a new flag was introduced
to indicate whether the flags shall be removed either by dialog or
tm.

(cherry picked from commit 6852bd4)

* Fix a PKG leak in the SIP message processing stack

Commit 7464a86ec introduced a processing context leak during the
handling of basically any SIP request in all protocol stacks
except for HEP.

Reported by Trevor Francis <trevor@46labs.com>

(cherry picked from commit 731719a)

* [acc][bugfix] register tm free function only once

(cherry picked from commit 92d2041)

*  [sipcapture][HOMERv5 incompatibility fix] HOMERv5 table rotation aware logic

    * HOMVERv5 allows rotating tables by having a prefix which is
    the fixed table name and a suffix which is a string containig
    timestamps
    * sip_capture now accepts table name as a parameter to sip_capture()
    function
    * both global table name and sip_capture table_name can have
    a prefix(string) and a suffix(strftime format string);
    * fixed bugs in async query building

(cherry picked from commit 074463f)

* [sipcapture][HOMERv5 incompatibility fix]generic capturing function

      Added new function called report_capture which allows
capturing hep packets in a generic format. It will be very
effective for the third version of the hep protocol for capturing
packets other than SIP. Also added a new table called rtcp_capture
for storing everything capture with report capture.

(cherry picked from commit c5700cc)

* [sipcapture][HOMERv5 incompatibility fix] updated docs for report_capture and new table name format

(cherry picked from commit 5d725a4)

* Fix typo in do_accounting() naming is cfg templates

(cherry picked from commit 7f8656e)

* Fixed bogus pkg_free on pointer in data segment

Reported by @dzhou121
Closes OpenSIPS#854

(cherry picked from commit b9aa873)

* MI library: Add comments regarding a known issue

Currently, MI arrays cannot contain objects with non-identical
"name" attributes.

This patch also quickfixes this issue in mi_list_all_profiles() by dropping
the array idea altogether, in favour of a top-most object.

(cherry picked from commit 6c10501)

* [tm]fix context functions header

(cherry picked from commit 59e5a41)

* [context][bugfix] each context has its own destroy functions vector

Credits to Razvan Crainea

(cherry picked from commit 53263b2)

* [siptrace][bugfix] sequential requests - set context for sl callbacks

(cherry picked from commit 943d901)

* [proto_hep][bugfix] check memory allocation

(cherry picked from commit f5ad753)

* tls_list() may be called even without DB support

Avoid locking if DB support was not enabled.

(cherry picked from commit e6944bb)

* exclude proto_wss, use QM_MALLOC

* Fixed default FIFO file name

(cherry picked from commit ffdbb97)

* Fixed MI nodes in 'sip_trace' command.

Formatting chars must not be included in the MI tree

(cherry picked from commit 7811e2d)

* [acc][bugfix] correctly store do_accounting() flags

	Flags are now moved from processing context into
transaction context when the transaction is created, this way
having visibility for the whole transaction.

(cherry picked from commit 41bcd25)

* [proto_hep][bugfix] fix bad sip payload size calculation

(cherry picked from commit eec5045)

* [sipcapture] remove time-consuming unnecessary chunk of code

(cherry picked from commit cc7a2ea)

* [sipcapture] fix incompatibilities with HOMERv5 db schema

(cherry picked from commit f756878)

* [siptrace][bugfix] avoid double free on cancelled transaction

(cherry picked from commit 3c6b693)

* [tls_mgm] properly handle SSL_ERROR_SYSCALL on SSL_shutdown

(cherry picked from commit bdcee39)

* Fixed arrays in clusterer_list MI command

(cherry picked from commit 31943a4)

* Fixed wrong MI tree in clusterer_list (related to previous commit)

(cherry picked from commit fa4e7f0)

* Avoid space in MI node name

* Enable debug_mode settings only if debug_mode gets set to enable.

(cherry picked from commit e7c14bc)

* [hep][bugfix] correctly store ports/addresses

(cherry picked from commit 51e6f102daac7d0de9a7ca4efea74d5c559746fe)

* Revert "[hep][bugfix] correctly store ports/addresses"

This reverts commit 7b1359a.

(cherry picked from commit ab22929)

* [proto_hep][bugfix] use the correct port when unpacking

(cherry picked from commit 3dda413)

* [siptrace][bugfix] use the correct sockaddr structure for storing

(cherry picked from commit 556f394)

* [drouting] bug fix and memory leak fix

* free gateways list for each carrier at reload
* use map_find instead of map_get to search an element in the tree

(cherry picked from commit f9f3b83ef621850c2c128b12b9bf6ab2e78e5ee1)

* [fix functional bug]allow a module to register multiple protocols

(cherry picked from commit 0873c14)

* [fix functional bug][hep] multiple versions/protocols can be used in the same time

Since commit 0873c14 multiple
network protocols can be used from one module. Proto_hep was changed
to be able to use both tcp and udp in the same time. Moreover, there
is no hep_version needed since we can receive HEPv1,v2 and v3 on any
UDP interface. Since HEPv1 and v2 are not compatible with TCP, only
HEPv3 will be support. For HEPv3, Sipcapture module can now relay
packets from TCP to UDP or the reverse way.
Siptrace module was also improved. Trace id's can now be defined with
hep version and transport protocol, in order to be able to do multiple
types of tracing with different HEP protocols and/or network transports.

(cherry picked from commit 45a3aef)

Conflicts:
	modules/siptrace/siptrace.c

* [hep] updated docs for previous commit

(cherry picked from commit f9c6cdd)

* [proto_hep] correctly name function

(cherry picked from commit 853b0bb)

* [fix functional bug][sipcapture] new HEPVERSION script variable

(cherry picked from commit 136fcb6)

* [sipcapture] updated docs for HEPVERSION

* [siptrace] fix bad cherry-pick conflict solving

* proto_bin: remove debug INFO message

(cherry picked from commit d388e80)

* [acc][bugfix] fix memory leak

* fix leak caused by missed calls - receiving a negative reply
caused flags not being freed

* regex: fix spell-check in package

(cherry picked from commit 647ea21)

* dialog and usrloc: broadcast replication data all time

This prevents clusterer module from marking a node as not reachable when there
is no traffic at all.

Fixes OpenSIPS#849

(cherry picked from commit 7f7f871)

* debian: add missing dependency

Ovewrite lintian warning

* Makefile.conf: add deps for tls_mgm and proto_wss

This prevents 'make menuconf' from deleting these modules from the generated
configuration file

(cherry picked from commit 616b2ba)

* ratelimit: initialize the length of the algorithm

(cherry picked from commit 0eebf10)

* [sipcapture] be able to set proto_type in report capture function

(cherry picked from commit e3466c4adecf11fa6d7da206359847c3a1c4b0f9)

* [sipcapture] fix bad conditions

(cherry picked from commit 4caa2ac)

* Updated opensipsctl.base to also search /sbin

The md5 utility is located at /sbin/md5 on FreeBSD 8.3. An additional common location was added to allow the script to accommodate this.
(cherry picked from commit ca87f55)

* [sipcapture][bugfix] invalid memory access

(cherry picked from commit 8056a984ce914d6585aef6054d727d82f72da3c6)

* dialog: Remove a chunk of dead code

(cherry picked from commit fd33057)

* [sipcapture][bugfix] invalid static vector size calculation

(cherry picked from commit b8a82b1)

* [siptrace][bugfix] fix trace_id parsing

(cherry picked from commit 2878741)

* [sipcapture][bugfix] fix bad string hex value parsing

(cherry picked from commit 5d6b927d41988e3170ab37889fb26c8026dce29d)

* [sipcapture] fix new hep proto names string

(cherry picked from commit 3c15d2d)

* [sipcapture] allow any hep version for hep_net variable

(cherry picked from commit bcbded5)

* [siptrace] fix hash calculus for extended hep trace_id

(cherry picked from commit 5e261d7)

* event_flatstore doc: Fix some typos

(cherry picked from commit 3cedcc4)

* event_virtual doc: Fix grammar/typos

(cherry picked from commit 3fd9686)

* [siptrace][bugfix] bad structre used when printing HEP trace_id via mi

(cherry picked from commit 8c6d9ba)

* [sipcapture] fix sip_capture table schema

(cherry picked from commit 8fd97163058c798f45d381b124cc465261e9e1e5)

* [nathelper] fix bad logic regarding the timer list

(cherry picked from commit a86d2c4)

* Update name to opensips-2.2.0-rc1

* Update ChangeLog for 2.2.0-rc1

* [dispatcher] fix double allocation issue

(cherry picked from commit d6891363e3b3b4047a1948eb03fb6b6bab285885)

* [sipcapture] fix bad time calculation

(cherry picked from commit d54dc2d)

* [sipcapture] fix possible data type loss

(cherry picked from commit 1c811ce)

* Fixed bogus memory operations.

Fixed bogus free (of uninit pointer) if parse_contact() fails
Fixed shm leak on errors after print_rr_body
Fixed shm leak on success if record_route is present.
Reported by John Nash.

(cherry picked from commit 4b0fca5)

* nathelper: ping WSS clients when using natping_tcp

See ticket OpenSIPS#875

(cherry picked from commit 54a306a)

* [mi_json] return code rework for errors

	Mi_json now returns only 200 OK as HTTP code. We have two
records for inspecting mi level errors, "code" for the error code
and "reason" for the error message.

(cherry picked from commit 644ea29)

* [mi_json] remove double inverted commas for internal error messages

(cherry picked from commit b5a51a9)

* [mi_json] return jsonrpc compliat error message

(cherry picked from commit 26a66f6aa2fb957a16ed000cc10360bf5f648e18)

* usrloc: Fix some uninitialized memory issues

Reported by Minh Phan
Closes OpenSIPS#878

(cherry picked from commit 38f525d)

* [mi_json] minor fixes in mi_json

(cherry picked from commit c091d068768d76fe34ea67ebb010b30082d55ca5)

* [mi_xmlrpc] return code rework for errors

Mi_xmlrpc_ng now returns only 200 OK as HTTP code. We have two
labels for inspecting mi level faults, "code" for the error code
and "message" for the error message. Check
http://www.tutorialspoint.com/xml-rpc/xml_rpc_fault.htm for
more details.

(cherry picked from commit 2bb871d0e77a739aac310235a1d042f3241d02e0)

* Fixed preserving 3xx Contacts in TH without dialog

Reported by Pete Kelly.
Closes OpenSIPS#656.

(cherry picked from commit 6184b96)

* [dispatcher] multiple fixes

* use pkg memory instead of shm for fixup variables
* fix int list building - avoid building a circular list

* Fix bogus timer ref counter during expire update.

Many thanks to Trevor Francis for reporting and helping with troubleshooting and testing.

(cherry picked from commit 047b1b3)

* Process sequential messages received in CONFIRMED_NA state

Due to UDP race conditions, sequential messages may be received
before the ACK confirming the initial INVITE ( eg. Re-INVITE sent
immediately as the call is established in order to force
a specific codec ) - also push these requests through the whole
dialog processing in order to avoid any future issues ( eg. CSEQ
updating which, if left unprocessed, will lead to generating out
of order sequentials by OpenSIPS )

(cherry picked from commit bfaf022)

* Fix a string concatenation operator bug

This patch fixes an issue with string concatenation where any NULL
operand would cause all operands to its left to be ignored when
computing the result of the expression.

Reported by Ovidiu Sas
Closes OpenSIPS#870

(cherry picked from commit a420752)

* clusterer: Fix bad doc example

Reported by "alias_neo" on IRC

(cherry picked from commit fd0ddaa)

* re-register topo hiding callbacks after restart

Thanks to Pete Kelly for reporting this

(cherry picked from commit 4c84bd8)

* th: fix dlg flag check

(cherry picked from commit 1b5802d)

* Fix invalid memory access with async MySQL queries

Due to the way the libmysqlclient query result strings were managed,
they would be freed by the library before OpenSIPS would copy them
into the output AVPs.

This patch fixes the issue by adding a new DB API function which handles
the cleanup of async query results.

Reported by Ovidiu Sas
Addresses issue OpenSIPS#873

(cherry picked from commit 177c60a)

* Upgrade to release candidate 2

* Update ChangeLog for OpenSIPS 2.2.0-rc2

* Added extra log message on openssl 1.0.1e-fips bug.

If CRYPTO_set_mem_functions() fails, make a note on the openssl 1.0.1e-fips bug, so users may have a hint on the actual issue.
See more  OpenSIPS#834.
Closes  OpenSIPS#834.

* Fix potential 100 Trying duplicates.

Added the "auto_100trying" module parameter to allow the script writter to take control (from script level) over when the 100 Trying reply is to be sent back.
By default, the reply is automatically generated when the INVITE transaction is created.
Fixes OpenSIPS#833

(cherry picked from commit b023c93)

* [mmgeoip] allow chosing memory caching type

	Before GEOIP_MMAP_CACHE was used causing a segmentation
fault when database file was changed. Now users can choose between
reading the database directly from file, cahing it into memory with
the possibility to change the database file at runtime.

(cherry picked from commit ecf5032aaafbe5a93bbfc3562c4b3358548839e7)

* Revert "Accept TCP aliases by default"

This reverts commit d62bc96.

Firstly, TCP connection reusage (RFC 5923) should only be employed between
TLS endpoints - only TLS allows the endpoints to authenticate each other
during connection setup, preventing unauthorized connection hijacking.

Secondly, aside from any security considerations, RFC 5923 must
not be employed fanatically (Proxy-Proxy, Edge-UA, UA-Proxy) on any TCP
connection (especially disregarding the ";alias" Via parameter!), but
rather only between adjacent SIP entities who can both initiate a
connection towards each other, and also support the RFC. In the real
world, we're basically only talking about the Proxy-Proxy usage case, as
any SIP UA scenario will most likely involve some form of NAT and a
Proxy that cannot open connections backwards, towards the UA. In these
cases, TCP connection reusage is _completely_ out of the question, as a
single UA might end up receiving all calls of all users behind their
public IP.

Thanks to Jonas Borjesson for reporting the problem in the first place.

(cherry picked from commit 715339f)

* TCP connection lookup: Add matching by transport

The fact that all currently supported TCP-oriented protocols have different
standard ports is not an excuse for not including the transport into the
match condition (i.e. dest IP address + dest port + dest transport).

This may very well prevent issues with messages being sent out over the
wrong TCP connection in a number of scenarios where we employ TCP connection
reusage over both plain TCP and TLS with a Proxy that specifies the same port
in the topmost Via header when it establishes each of the two connections.

(cherry picked from commit 13970bb)

* TCP alias lookup: Add matching by transport

Further improving commit 13970bb.

(cherry picked from commit ea699f0)

* mi_xmlrpc_ng: Fix a shared memory leak

(cherry picked from commit d047e10)

* mi_xmlrpc_ng: Fix NULL pointer dereference

Any MI tree with a topmost Array structure would have caused a crash

(cherry picked from commit 555fb8a)

* mi_xmlrpc_ng: Remove an incorrect free operation

Completes commit d047e10

(cherry picked from commit 99f039e)

* Fixed typo

(cherry picked from commit 1503ca6)

* Obey USE_SYSV_SEM and USE_PTHREAD_MUTEX.

If USE_SYSV_SEM or USE_PTHREAD_MUTEX are defined via Makefile.conf, do you force autodetection (based on arch type) of the locking support.

(cherry picked from commit 39592dc)

* Fix bogus destroy of a RW lock.

(cherry picked from commit 83f3945)

* Proper support for USE_POSIX_SEM option in Makefile

(cherry picked from commit 5e40aaf)

* Fix bogus set locking functions.

It is used for SYSTEM V locking only, looks like a copy'n'paste error.

(cherry picked from commit 4bcdf4e)

* Fix warning in SYSTEM V locking functions

(cherry picked from commit 53b3f40)

* call_center: obey lock_set interface

* acc: Remove deprecated modparam dependency

(cherry picked from commit d983d28)

* acc: properly detect parsing errors

(cherry picked from commit d6a44c0)

* dialplan: Fix a rule tie-breaking bug

When an input string would match both a "string" rule and a "regex"
rule, the priority based tie-breaking was incorrect (now favouring
the bigger priority instead - opposite to default module behavior).

Thanks to @paolodepa for suggesting this fix
Fixes issue OpenSIPS#696

(cherry picked from commit cbdd79a)

* Update makefile to support gcc 6.1

* dialplan: Improve documentation

Added paragraphs regarding rule types along with explanations on
they way priorities and rule tie-breaking work.

(cherry picked from commit 46894f8)

* dbtext: convert DBG to ERR for better debugging

(cherry picked from commit 0f08b26)

* clusterer: proper translation to bigint for dbtext

This creates the proper type for bigint in the clusterer table for dbtext

Thanks go to Trevor Francis from 46Labs for reporting this
Close OpenSIPS#699

(cherry picked from commit 5bae373)

* Improve error reporting for unknown script vars

Fixes OpenSIPS#574

(cherry picked from commit 97ace29)

* Fixed missing MI reply on pua_publish.

Properly send an MI reply for the async pua_publish with Expires 0.
Many thanks to Damien Sandrs for invetigating and reporting.

Closing OpenSIPS#657

(cherry picked from commit 60d01ef)

* add license to rw_locking.h header

(cherry picked from commit e3a57ac)

* Link the dialog cell into internally generated requests from the dialog module

Fixes OpenSIPS#839

(cherry picked from commit 66937a2)

* [acc] fix double free issue for multiple dlg callbacks

	The last byte in acc flag mask now holds a ref counter in
the last byte. The counter is increased each time a dialog callback
is invoked, and decreased for each free function corresponding to
a callback. When the ref counter reaches 0, flags can be freed.
The atomicity of the ref counter is based on the fact that
dialog callbacks and their free functions are called sequentially,
one after the other.
ACC_DIALOG_CONTEXT and ACC_CDR_REGISTERED flags where moved in the
7th byte of the flags.

(cherry picked from commit 7834aa5)

* promote 2.2.0-rc2 to stable

* Update ChangeLog with latest changes

* Disable QM and DBG for memory manager.

* Fixed proper cleanup on failure of tcpconn_new()

The chances for going for error cases are very low, still let's do it in the proper way

(cherry picked from commit 57c163b)

* If POSIX sems are used, be sure to link against pthread lib

(cherry picked from commit f7de640)

* Fixed interface matching in loose_route()

If port is missing in Route URI, do not assume default 5060, but consider the schema and protocol (they may require a different default port).
Ex: sip:10.0.0.5;transport=tls was previously handled as sip:10.0.0.5:5060;transport=tls, which is wrong as the default TLS port is 5061
Reported on mailing list by Ravitez Dondeti.

(cherry picked from commit 3593a5f)

* sync changelog for latest 2.2.0

* Fix documentation on former b2bl_key_avp module param

(cherry picked from commit ca21c6d)

* load_balancer: Fix a possible crash

Could have led to a segfault when OpenSIPS would run oom

Reported by Qasim Khan

(cherry picked from commit 4081fa3)

* Proper handle the case of no usrloc domain registered.

Prevent get_next_udomain() crashing if there are no usrloc domains registered (reported by Qasim Akhan on users mailing list.
Do not enable the pinging support in nathelper if usrloc has no registered domains.

* Fix error handling in DB writes.

If inserting/updating a dlg record in DB fails, do not exit with error, but continue with the rest of the dialogs.
Credits for finding and reporting this go to Rik Broers @ Motto

(cherry picked from commit 0ca6cf0)

* Removed unused "error" jump label

(cherry picked from commit 5819b0f)

* Removed wrong "NOT NULL" constraint over the contact DB fields

The code actually handles the case of NULL callee / caller contacts, so DB must allow NULL values.

* Removed compilation warning

implicit declaration of function â"sched_yield" [-Wimplicit-function-declaration]

* [mi_xmlrpc_ng] fix fault incompatibilities with xmlrpc standard

(cherry picked from commit d57c2fd)

* Consider WSS also a SIPS protocol

Reported by Varghese Paul ( @varghesepaul )
Closing OpenSIPS#899.

(cherry picked from commit 39e0deb)

* Fix evaluating the SIP port from a SIP URI.

Use the new function get_uri_port() to evaluate the port and proto, in a SIP wise manner, form a SIP URI. If port/proto are not explicitly set in the URI, consider the default port for the used transpor proto. If protocol misses, we assume the default protos according to the URI schema.

NOTE: it is completly bogus (and dangerous) to assue 5061 if SIPS schema is used as:
1) SIPS can use used with WSS, which actually has 443 port
2) TLS can pe required via transport param in a SIP schema URI too

(cherry picked from commit 4c54bcd)

* Fixed migration of Call Center tables

Reported by John Quick.

* Fixed forcing FAST LOCKS for arm6.

Use FAST locking support for arm6 too.
For Linux, use POSIX as default locking support.

(cherry picked from commit 058e16f)

* Fix docs on missing module dependency.

If replicate_contacts_to parameter is turned on, usrloc depends on the clusterer module.
Credits go to Sammy on mailing list.

(cherry picked from commit 735958d)

* [acc][bugfix] enable acc flags refcount only after dlg callbacks called

(cherry picked from commit a9a8fba51da95d3244ab46e22b3ed6cd8d0bea9e)

* Fix memory corruption on $stat() vars

The $stat() var specs are kept in pkg, while the name (if stat not found) is kept in memeory. This means all the copies (form all procs) of the specs will point to a single shm block. It is not safet to free this block as you have no idea how many copies of the spec (from other processes) still refer the name.
Closes OpenSIPS#902

(cherry picked from commit 4baead7)

* Fixed failure to enable NAT pinging.

Commit 8f0c677 introduces a bug in testing is usrloc domains are available, and if not, to disable the NAT pinging in nathelper. The test is wrong as it is done in mod_init, while registrar module registerd the usrloc domain via fixup function, after the mod_init section.

Reported by Nick Altmann

(cherry picked from commit f150fb7)

* Add support for SIP URIs without user part in 'avpops' module.

This module provides a set of avp_db_xxx functions which take pseudo
var and flag as first argument. Flag can be one of username, domain,
uri or uuid. Previosly avp_db_xxx functions used to return an error if
flag has been set to username, domain or uri and specifed pseudo var
did not contain username and host after parsing as SIP URI. This
behaviour seems to be strange because if flag is being set to
domain/username and sip URI contains domain/username we can still
load/store/delete this variable.

(cherry picked from commit 459f2e9)

* Update rtpproxy.c

When building I/O vector for command to rtpproxy in "force_rtp_proxy_body", after an IPv6 address is detected and the "6" option is added, increase the length component in the I/O vector so it is passed correctly.
(cherry picked from commit 4e73871)

* Update rtpproxy.c

When moving stored parameters from Branch AVP to Dialog variable, make sure that the integer value "setid" is handled correctly so that it remains valid for the remainder of the dialog.
(cherry picked from commit e267e9e)

* rtpproxy: no need to update the len for IPv6

(cherry picked from commit 5cfd916)

* Fix proper testing of context content

If a STR is register to the context, a valid STR * will be always returned , so we need to test the content, not the pointer.

* Update packaging to 2.2.0

* [sqlite][bugfix] free column names when freeing the result

(cherry picked from commit cf380773cec9f91ad08e343c03261154dabc36a5)

* init: use the specified CFGFILE in debian init

In case the CFGFILE changes in the init script, opensips will still start with
the compiled file instead of the one configured

(cherry picked from commit 030efef)

* Fix wrong number of columns when preloading via a DB backend without Fetch support.

* proto: always populate default values for protocols name and port

This allows you to print the protocol you received, and its associated port

(cherry picked from commit 0ae5ba2)

* Allow proto modules to populate its name

(cherry picked from commit 00d052c)

* Fix dialplan module when using db_text backend.

The db_text makes no difference between NULL or "empty string" values in DB -> both are internally translated as NULL . The dialplan module, in a very abusive way, forces "not null" (in DB schema and in the code for data validation) even for columns that are optional (like subst_exp, repl_exp, timerec and attrs). Besides being bogus (if a column is not to be used, you have to set it to empty string rather than let it NULL), it makes impossible the usage of db_text with dialplan.
This fix allows (DB and code) the mentioned DB columns to be also NULL.
The change is backward compatible, it should not break any existing usage of the dialplan module.

* Fix compiler warning

Using gcc 4.8.4, we would get:

net/trans.c:43:2: warning: missing initializer for field ‘name’ of
‘struct proto_info’ [-Wmissing-field-initializers]
  { }, /* PROTO_NONE */
    ^

(cherry picked from commit 376579f)

* [siptrace][bugfix] fix bad macro in siptrace(trace local ip logic)

This commit closes OpenSIPS#916
Thanks to @Tinet-AaronAn for reporting the issue

(cherry picked from commit 2a4f686d4997b814eeaa425dc23fe822cb8ef91a)

* module statistics: Properly update the "real_used" memory stat

(cherry picked from commit bc34043)

* Fix memory leak: after sqlite prepare was deleted stmt compiled, freed error message after sqlite exec, allocated rows was set to free and it also db_free_row was repaired.

* [db_sqlite] use DB_STRING type when the column value type is DB_STRING

(cherry picked from commit a2c7994)

Conflicts:
	modules/db_sqlite/row.c

* [db_sqlite] add explanation about implementation

(cherry picked from commit 3ab8237)

* [sqlite] fix warning

(cherry picked from commit 0b4cbaa)

* permissions: fix get_source_group() return

In case a group is not found, return -1 instead of true

* acc: Fix incorrect Request-URI handling

If the config script does not include any Request-URI altering logic
(e.g. no lookup() or $ru manipulation), the acc module would incorrectly fill
in a "msg->new_uri" field which should NOT be freed into the SIP request
structure, leading to the memory pool being corrupted upon transaction release.

Credits to Guillaume Lacroix for reporting

(cherry picked from commit 02cb9f0)

* fix core database engine bug introduced with commit 980f15e

(cherry picked from commit db37c5c411b529acd0cfeee4dfbc7925db6c2901)

* [db_sqlite] fix memory management bugs

* core free function was used to free starting with commit 980f15e
which was not freeing the memory correctly(result rows were
allocated all at once, but in the current version they were freed
once at a time);
* check if memory is allocated to prevent core dumps;

(cherry picked from commit bb506d2563c2670094537e70cc35b85d4ce4cd80)

* [db_sqlite] remove unnecessary file introduced in commit ccda718

(cherry picked from commit 450265ff4032e4d316d21fa6890946bed2866f87)

* Fix script varibles for providing port and proto (as part of SIP URI).

If the SIP URI does not have an explicit port or proto, determine the default port/proto in a SIP wise manner (rather than returning 5060 / UDP) (Ex: sip:example.com;transport=tls has default port 5061 and not 5060 ; or sips:example.com has default proto TLS and not UDP).

Affected variables are $dp, $rp, $op and $dP, $rP, $oP

(cherry picked from commit 6cc850e)

* Fixed compiling on arm6 with fastlocks

Partial revert of 058e16 as we need some extra asm code for fast locking on arm6.
See OpenSIPS#923
Closes OpenSIPS#912

(cherry picked from commit a69c328)

* Fix error message when a route is not defined.

Print the name of the route too - the ID is irrelevant for the script writter.

(cherry picked from commit 4094818)

* dialog: advance to next cell in case of error

(cherry picked from commit 70db2cf)

* [acc][bugfix] check if database loaded before using its handler

(cherry picked from commit 8dd10d85b408947576223e75a67228ed7c7abd91)

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

(cherry picked from commit 0495faa)

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

(cherry picked from commit 97f309c)

* Fix populating blacklists.

When creating the blacklists, use the port and protocol of the destination too, otherwise the rules may conflict or be too wide to be used (like 2 destinations with same IP but different ports).

(cherry picked from commit 7fa9cee)

* add debian packaging for proto_wss, proto_tls and tls_mgm

Reported by Rik Broers
Close OpenSIPS#931

* Fix advertised port and address per branch.

Before the advertised_port/address are preserved only in the UAS part of the transaction - that means it is only one value and it is from the setting done in Request Route; whatever later setting done in Failure Route or Branch Route are not preserved at transaction level (even if they are used on the spot, for sending out the INVITE).
So, when we have to build a local request (ACK or CANCEL), we do not remember which specific address/port were advertised for that particular UAC (branch).

Fixes OpenSIPS#917.

(cherry picked from commit eb850a2)

* Fix building Via Branch in stateless mode

Instead of copying the branch value from a previous statefull Via header (which may lead to overflow as OpenSIPS has a maximum value for the built branch), we generate a new branch value based on the previous Via branch - in this way, we have full controll over the length of the resulting Branch and we also inherit the uniqueness of the branch value (from the prev Via hdr).

Reported by Gupta, Rahul and Elliott, Ray

(cherry picked from commit 482e643)

* rest_client: Fix incorrect trim operation

(cherry picked from commit d8bf10d)

* permissions: allow any supported protocol

Before this commit, the protocol check was hardcoded in the module. This
commit allows to add in the permissions table any transport protocol
supported.

Thanks go to Kirill Galinurov for reporting this!

(cherry picked from commit 0eecff9)

* update version to 2.2.1

* Update ChangeLog for 2.2.1

* Fixed memory leak on modules/drouting/drouting.c

This leak occures in function get_group_id() when do_routing is called without parameters in opensips.cfg.
In this case the dr_default_grp variable is not equal -1 and 'return dr_default_grp' is executed without freeing the res variable previously allocated for query execution.

(cherry picked from commit 6573994)

* Remove unnecessary test.

"res" cannot be null at that point

(cherry picked from commit 0b60681)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants