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

Fix memory leak: after sqlite prepare was deleted stmt compiled, free… #919

Merged
merged 1 commit into from Jun 30, 2016

Conversation

Danfx
Copy link

@Danfx Danfx commented Jun 29, 2016

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.
These points were made:

  1. In function db_sqlite_free_result, it was added a sqlite3_finalize. This implies on free sqlite statements allocated from sqlite3_prepare_v2 called by functions db_sqlite_raw_query and db_sqlite_query.
  2. In function db_sqlite_free_result was changed to call db_free_result. It is a reuse suggestion.
  3. In function db_free_row was fixed to free allocated rows. This function is called by db_free_result.
  4. In function db_sqlite_convert_row for lines that use pkg_malloc, the flag VAL_FREE was set to enable. This flag was changed to db_free_row free allocated rows content.
  5. After sqlite3_exec was included sqlite3_free, to free allocated error message by sqlite.

Best Regards,
Daniel Fussia

Inatel Competence Center
Embedded Software

…d error message after sqlite exec, allocated rows was set to free and it also db_free_row was repaired.
@ionutrazvanionita
Copy link
Contributor

Great patch, will merge! I will also put the patch in the 2.2 branch. Thank you very much for your contribution.

@ionutrazvanionita ionutrazvanionita merged commit 308ff0d into OpenSIPS:2.2 Jun 30, 2016
@ionutrazvanionita
Copy link
Contributor

ionutrazvanionita commented Jun 30, 2016

@Danfx please make another pull for the master branch.

EDIT: Fixed it

ionutrazvanionita pushed a commit that referenced this pull request Jun 30, 2016
Fix memory leak: after sqlite prepare was deleted stmt compiled, free…
(cherry picked from commit 308ff0d)

Conflicts:
	modules/db_sqlite/row.c
@Danfx
Copy link
Author

Danfx commented Jun 30, 2016

Ok, no problems I'll do it.
Thank you also for helping our team.

Regards,
Daniel Fussia
Inatel Competence Center
Embedded Software

jnewman02 added a commit to Vocalocity/opensips that referenced this pull request 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants