summaryrefslogtreecommitdiff
path: root/include/asterisk/utils.h
AgeCommit message (Collapse)Author
2017-12-08utils: Add convenience function for setting fd flagsSean Bright
There are many places in the code base where we ignore the return value of fcntl() when getting/setting file descriptior flags. This patch introduces a convenience function that allows setting or clearing file descriptor flags and will also log an error on failure for later analysis. Change-Id: I8b81901e1b1bd537ca632567cdb408931c6eded7
2017-11-06Fix ast_(v)asprintf() malloc failure usage conditions.Richard Mudgett
When (v)asprintf() fails, the state of the allocated buffer is undefined. The library had better not leave an allocated buffer as a result or no one will know to free it. The most likely way it can return failure is for an allocation failure. If the printf conversion fails then you actually have a threading problem which is much worse because another thread modified the parameter values. * Made __ast_asprintf()/__ast_vasprintf() set the returned buffer to NULL on failure. That is much more useful than either an uninitialized pointer or a pointer that has already been freed. Many uses won't have to check for failure to ensure that the buffer won't be double freed or prevent an attempt to free an uninitialized pointer. * stasis.c: Fixed memory leak in multi_object_blob_to_ami() allocated by ast_asprintf(). * ari/resource_bridges.c:ari_bridges_play_helper(): Remove assignment to the wrong thing which is now not needed even if assigning to the right thing. Change-Id: Ib5252fb8850ecf0f78ed0ee2ca0796bda7e91c23
2016-11-30res_rtp: Fix regression when IPv6 is not available.Guido Falsi
The latest Release candidate fails to create RTP streams when IPv6 is not available. Due to the changes made in September the ast_sockaddr structure passed around to create these streams is always of AF_INET6 type, causing failure when used for IPv4. This patch adds a utility function to check for availability of IPv6 and applies such check at startup to determine how to create the ast_sockaddr structures. ASTERISK-26617 #close Change-Id: I627a4e91795e821111e1cda523f083a40d0e0c3e
2016-09-30astobj2: Add backtrace to log_bad_ao2.Corey Farrell
* Compile __ast_assert_failed unconditionally. * Use __ast_assert_failed to log messages from log_bad_ao2 * Remove calls to ast_assert(0) that happen after log_bad_ao2 was run. Change-Id: I48f1af44b2718ad74a421ff75cb6397b924a9751
2016-09-29core: Remove ABI effects of LOW_MEMORY.Corey Farrell
This allows asterisk to compiled with LOW_MEMORY to load modules built without LOW_MEMORY. ASTERISK-26398 #close Change-Id: I24b78ac9493ab933b11087a8b6794f3c96d4872d
2016-08-19Fix naming mismatch of allocator functions.Corey Farrell
Allocator functions that take file/line/func parameters are prefixed with single-underscore when MALLOC_DEBUG is not defined, double-underscore when it is defined. This change updates all allocators that accept file/line/func to have the same prototype in either ABI mode. The parameter order of __ast_vasprintf and __ast_asprintf in utils.h have been changed to match that of astmm.h. End-use allocator macro's have been removed from astmm.h and moved to an unconditional part of utils.h. Change-Id: I823bb6ce2b5675b3a4735948f10a3b420e9a023a
2016-08-15core: Entity ID is not set or invalidAlexei Gradinari
The Exchanging Device and Mailbox States could not working if the Entity ID (EID) is not set manually and can't be obtained from ethernet interface. This patch replaces debug message to warning and addes missing description about option 'entityid' to asterisk.conf.sample. With this patch the asterisk also: (1) decline loading the modules which won't work without EID: res_corosync and res_pjsip_publish_asterisk. (2) warn if EID is empty on loading next modules: pbx_dundi, res_xmpp Starting with v197 systemd/udev will automatically assign "predictable" names for all local Ethernet interfaces. This patch also addes some new ethernet prefixes "eno" and "ens". ASTERISK-26164 #close Change-Id: I72d712f1ad5b6f64571bb179c5cb12461e7c58c6
2016-07-19Add conditional support for noreturn functions.Corey Farrell
This adds support for tagging functions with the noreturn attribute. If DO_CRASH is enabled then ast_do_crash never returns. If AST_DEVMODE and DO_CRASH are enabled then failed assertions never return. This can resolve a large number of false positives with static analyzers. ASTERISK-26220 #close Change-Id: Icfb61e5fe54574eced4c3e88b317244f467ec753
2015-12-14Fix sscanf() format string type mismatch.Richard Mudgett
ASTERISK-25615 Reported by: George Joseph Change-Id: Ieff35307254ca193f3d473cff2e396ca57c7ce0b
2015-12-12pjsip/config_transport: Check pjproject version at runtime for async opsGeorge Joseph
pjproject < 2.5.0 will segfault on a tls transport if async_operations is greater than 1. A runtime version check has been added to throw an error if the version is < 2.5.0 and async_operations > 1. To assist in the check, a new api "ast_compare_versions" was added to utils which compares 2 major.minor.patch.extra version strings. ASTERISK-25615 #close Change-Id: I8e88bb49cbcfbca88d9de705496d6f6a8c938a98 Reported-by: George Joseph Tested-by: George Joseph
2015-12-08res_pjsip: Add existence and readablity checks for tls related filesGeorge Joseph
Both transport and endpoint now check for the existence and readability of tls certificate and key files before passing them on to pjproject. This will cause the object to not load rather than waiting for pjproject to discover that there's a problem when a session is attempted. NOTE: chan_sip also uses ast_rtp_dtls_cfg_parse but it's located in build_peer which is gigantic and I didn't want to disturb it. Error messages will emit but it won't interrupt chan_sip loading. ASTERISK-25618 #close Change-Id: Ie43f2c1d653ac1fda6a6f6faecb7c2ebadaf47c9 Reported-by: George Joseph Tested-by: George Joseph
2015-04-22Fix/Update clang-RAII macro implementationDiederik de Groot
- When you need to refer to 'variable XXX' outside a block, it needs to be declared as '__block XXX', otherwise it will not be available with- in the block, making updating that variable hard to do, and ast_free lead to issues. - Removed the #error message because it creates complications when compiling external projects against asterisk For example when using a different compiler than the one used to compile asterisk. The warning/error should be generated during the configure process not the compilation process ASTERISK-24917 Change-Id: I12091228090e90831bf2b498293858f46ea7a8c2
2015-04-09clang compiler warnings: Fix autological comparisonsMatthew Jordan
This fixes autological comparison warnings in the following: * chan_skinny: letohl may return a signed or unsigned value, depending on the macro chosen * func_curl: Provide a specific cast to CURLoption to prevent mismatch * cel: Fix enum comparisons where the enum can never be negative * enum: Fix comparison of return result of dn_expand, which returns a signed int value * event: Fix enum comparisons where the enum can never be negative * indications: tone_data.freq1 and freq2 are unsigned, and hence can never be negative * presencestate: Use the actual enum value for INVALID state * security_events: Fix enum comparisons where the enum can never be negative * udptl: Don't bother to check if the return value from encode_length is less than 0, as it returns an unsigned int * translate: Since the parameters are unsigned int, don't bother checking to see if they are negative. The cast to unsigned int would already blow past the matrix bounds. * res_pjsip_exten_state: Use a temporary value to cache the return of ast_hint_presence_state * res_stasis_playback: Fix enum comparisons where the enum can never be negative * res_stasis_recording: Add an enum value for the case where the recording operation is in error; fix enum comparisons * resource_bridges: Use enum value as opposed to -1 * resource_channels: Use enum value as opposed to -1 Review: https://reviewboard.asterisk.org/r/4533 ASTERISK-24917 Reported by: dkdegroot patches: rb4533.patch submitted by dkdegroot (License 6600) ........ Merged revisions 434469 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 434470 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434471 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-30Fix an ABI compatibility issue with ast_log_safe for modules.Corey Farrell
Binary modules are sometimes built against the latest release of Asterisk in each branch, and need to be compatible with all releases of that branch. This change ensures that utils.h only uses ast_log_safe from the core. For modules and utilities ast_log is used instead. Review: https://reviewboard.asterisk.org/r/4548/ ........ Merged revisions 433772 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 433773 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433774 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-27Fix link error for utils/aelparse.Corey Farrell
Use the standard ast_log instead of ast_log_safe for STANDALONE programs. Review: https://reviewboard.asterisk.org/r/4538/ ........ Merged revisions 433549 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 433550 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433551 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-27Improved and portable ast_log recursion avoidanceCorey Farrell
This introduces a new logger routine ast_log_safe. This routine should be used for all error messages in code that can be run as a result of ast_log. ast_log_safe does nothing if run recursively. All error logging in astobj2.c, strings.c and utils.h have been switched to ast_log_safe. This required adding support for raw threadstorage. This provides direct access to the void* pointer in threadstorage. In ast_log_safe, NULL is used to signify that this thread is not already running ast_log_safe, (void*)1 when it is already running. This was done since it's critical that ast_log_safe do nothing that could log during recursion checking. ASTERISK-24155 #close Reported by: Timo Teräs Review: https://reviewboard.asterisk.org/r/4502/ ........ Merged revisions 433522 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 433523 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433524 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-17core: Introduce chaos into memory allocationsScott Griepentrog
Locate potential crashes by exercising seldom used code paths. This patch introduces a new define DEBUG_CHAOS, and mechanism to randomly return an error condition from functions that will seldom do so. Functions that handle the allocation of memory get the first treatment. Review: https://reviewboard.asterisk.org/r/4463/ ........ Merged revisions 433060 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433063 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-03-12Add support for the clang compiler; update RAII_VAR to use BlocksRuntimeMatthew Jordan
RAII_VAR, which is used extensively in Asterisk to manage reference counted resources, uses a GCC extension to automatically invoke a cleanup function when a variable loses scope. While this functionality is incredibly useful and has prevented a large number of memory leaks, it also prevents Asterisk from being compiled with clang. This patch updates the RAII_VAR macro such that it can be compiled with clang. It makes use of the BlocksRuntime, which allows for a closure to be created that performs the actual cleanup. Note that this does not attempt to address the numerous warnings that the clang compiler catches in Asterisk. Much thanks for this patch goes to: * The folks on StackOverflow who asked this question and Leushenko for providing the answer that formed the basis of this code: http://stackoverflow.com/questions/24959440/rewrite-gcc-cleanup-macro-with-nested-function-for-clang * Diederik de Groot, who has been extremely patient in working on getting this patch into Asterisk. Review: https://reviewboard.asterisk.org/r/4370/ ASTERISK-24133 ASTERISK-23666 ASTERISK-20399 ASTERISK-20850 #close Reported by: Diederik de Groot patches: RAII_CLANG.patch uploaded by Diederik de Groot (License 6600) ........ Merged revisions 432807 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 432808 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432809 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-05config: Make text_file_save and 'dialplan save' escape semicolons in values.George Joseph
When a config file is read, an unescaped semicolon signals comments which are stripped from the value before it's stored. Escaped semicolons are then unescaped and become part of the value. Both of these behaviors are normal and expected. When the config is serialized either by 'dialplan save' or AMI/UpdateConfig however, the now unescaped semicolons are written as-is. If you actually reload the file just saved, the unescaped semicolons are now treated as start of comments. Since true comments are stripped on read, any semicolons in ast_variable.value must have been escaped originally. This patch re-escapes semicolons in ast_variable.values before they're written to file either by 'dialplan save' or config/ast_config_text_file_save which is called by AMI/UpdateConfig. I also fixed a few pre-existing formatting issues nearby in pbx_config.c Tested-by: George Joseph ASTERISK-20127 #close Review: https://reviewboard.asterisk.org/r/4132/ ........ Merged revisions 427275 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 427276 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-08-27CallerID: Fix parsing of malformed calleridKinsey Moore
This allows the callerid parsing function to handle malformed input strings and strings containing escaped and unescaped double quotes. This also adds a unittest to cover many of the cases where the parsing algorithm previously failed. Review: https://reviewboard.asterisk.org/r/3923/ Review: https://reviewboard.asterisk.org/r/3933/ ........ Merged revisions 422112 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 422113 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 422114 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 422154 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-12AST-2014-007: Fix DOS by consuming the number of allowed HTTP connections.Richard Mudgett
Simply establishing a TCP connection and never sending anything to the configured HTTP port in http.conf will tie up a HTTP connection. Since there is a maximum number of open HTTP sessions allowed at a time you can block legitimate connections. A similar problem exists if a HTTP request is started but never finished. * Added http.conf session_inactivity timer option to close HTTP connections that aren't doing anything. Defaults to 30000 ms. * Removed the undocumented manager.conf block-sockets option. It interferes with TCP/TLS inactivity timeouts. * AMI and SIP TLS connections now have better authentication timeout protection. Though I didn't remove the bizzare TLS timeout polling code from chan_sip. * chan_sip can now handle SSL certificate renegotiations in the middle of a session. It couldn't do that before because the socket was non-blocking and the SSL calls were not restarted as documented by the OpenSSL documentation. * Fixed an off nominal leak of the ssl struct in handle_tcptls_connection() if the FILE stream failed to open and the SSL certificate negotiations failed. The patch creates a custom FILE stream handler to give the created FILE streams inactivity timeout and timeout after a specific moment in time capability. This approach eliminates the need for code using the FILE stream to be redesigned to deal with the timeouts. This patch indirectly fixes most of ASTERISK-18345 by fixing the usage of the SSL_read/SSL_write operations. ASTERISK-23673 #close Reported by: Richard Mudgett ........ Merged revisions 415841 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 415854 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 415896 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415907 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-11-23res_pjsip: AMI commands and events.Kevin Harwell
Created the following AMI commands and corresponding events for res_pjsip: PJSIPShowEndpoints - Provides a listing of all pjsip endpoints and a few select attributes on each. Events: EndpointList - for each endpoint a few attributes. EndpointlistComplete - after all endpoints have been listed. PJSIPShowEndpoint - Provides a detail list of attributes for a specified endpoint. Events: EndpointDetail - attributes on an endpoint. AorDetail - raised for each AOR on an endpoint. AuthDetail - raised for each associated inbound and outbound auth TransportDetail - transport attributes. IdentifyDetail - attributes for the identify object associated with the endpoint. EndpointDetailComplete - last event raised after all detail events. PJSIPShowRegistrationsInbound - Provides a detail listing of all inbound registrations. Events: InboundRegistrationDetail - inbound registration attributes for each registration. InboundRegistrationDetailComplete - raised after all detail records have been listed. PJSIPShowRegistrationsOutbound - Provides a detail listing of all outbound registrations. Events: OutboundRegistrationDetail - outbound registration attributes for each registration. OutboundRegistrationDetailComplete - raised after all detail records have been listed. PJSIPShowSubscriptionsInbound - A detail listing of all inbound subscriptions and their attributes. Events: SubscriptionDetail - on each subscription detailed attributes SubscriptionDetailComplete - raised after all detail records have been listed. PJSIPShowSubscriptionsOutbound - A detail listing of all outboundbound subscriptions and their attributes. Events: SubscriptionDetail - on each subscription detailed attributes SubscriptionDetailComplete - raised after all detail records have been listed. (issue ASTERISK-22609) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/2959/ ........ Merged revisions 403131 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403133 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-23Fix memory corruption when trying to get "core show locks".Richard Mudgett
Review https://reviewboard.asterisk.org/r/2580/ tried to fix the mismatch in memory pools but had a math error determining the buffer size and didn't address other similar memory pool mismatches. * Effectively reverted the previous patch to go in the same direction as trunk for the returned memory pool of ast_bt_get_symbols(). * Fixed memory leak in ast_bt_get_symbols() when BETTER_BACKTRACES is defined. * Fixed some formatting in ast_bt_get_symbols(). * Fixed sig_pri.c freeing memory allocated by libpri when MALLOC_DEBUG is enabled. * Fixed __dump_backtrace() freeing memory from ast_bt_get_symbols() when MALLOC_DEBUG is enabled. * Moved __dump_backtrace() because of compile issues with the utils directory. (closes issue ASTERISK-22221) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/2778/ ........ Merged revisions 397525 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 397528 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397570 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-16utils.h: Minor formatting tweaks.Richard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396849 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-16Prevent heap alloc functions from running out of stack space.Walter Doekes
When asterisk has run out of memory (for whatever reason), the alloc function logs a message. Logging requires memory. A recipe for infinite recursion. Stop the recursion by comparing the function call depth for sane values before attempting another OOM log message. Review: https://reviewboard.asterisk.org/r/2743/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396822 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-03ARI - channel recording supportDavid M. Lee
This patch is the first step in adding recording support to the Asterisk REST Interface. Recordings are stored in /var/spool/recording. Since recordings may be destructive (overwriting existing files), the API rejects attempts to escape the recording directory (avoiding issues if someone attempts to record to ../../lib/sounds/greeting, for example). (closes issue ASTERISK-21594) (closes issue ASTERISK-21581) Review: https://reviewboard.asterisk.org/r/2612/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393550 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-03Shuffle RESTful URL's around.David M. Lee
This patch moves the RESTful URL's around to more appropriate locations for release. The /stasis URL's are moved to /ari, since Asterisk REST Interface was a more appropriate name than Stasis-HTTP. (Most of the code still has stasis_http references, but they will be cleaned up after there are no more outstanding branches that would have merge conflicts with such a change). A larger change was moving the ARI events WebSocket off of the shared /ws URL to its permanent home on /ari/events. The Swagger code generator was extended to handle "upgrade: websocket" and "websocketProtocol:" attributes on an operation. The WebSocket module was modified to better handle WebSocket servers that have a single registered protocol handler. If a client connections does not specify the Sec-WebSocket-Protocol header, and the server has a single protocol handler registered, the WebSocket server will go ahead and accept the client for that subprotocol. (closes issue ASTERISK-21857) Review: https://reviewboard.asterisk.org/r/2621/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393528 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-30Use the proper lower bound when doing saturation arithmetic.Sean Bright
16 bit signed integers have a range of [-32768, 32768). The existing code was using the interval (-32768, 32768) instead. This patch fixes that. Review: https://reviewboard.asterisk.org/r/2479/ ........ Merged revisions 386929 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 386930 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386931 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-04-26Example of how to use the Stasis message busDavid M. Lee
In order to get people familiar with the Stasis message bus, it would be useful to have something of a tutorial. Since I'm not clever enough to think of some cool integration we could do with Twitter, I settled for something that might actually be useful. This patch adds a res_statsd.so module, which implements a basic statsd[1] client. Statsd is a very simple statistics gathering server, which can publish its results to a backend graphing engine, like Graphite[2]. There are several different Statsd server implementations[3], so you can pick what works best for your environment. The actual example of how to use the Stasis message bus is in res_chan_stats.so. This module demonstrates how to use subscriptions and the message router by monitoring messages and posting channels stats to the statsd server. A wiki page walking through res_chan_stats.so is forthcoming. [1]: https://github.com/etsy/statsd/ [2]: http://graphite.readthedocs.org/en/latest/ [3]: http://joemiller.me/2011/09/21/list-of-statsd-server-implementations/ Review: https://reviewboard.asterisk.org/r/2460/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386624 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-01-12Fix XML encoding of 'identity display' in NOTIFY messages.David M. Lee
XML encoding in chan_sip is accomplished by naively building the XML directly from strings. While this usually works, it fails to take into account escaping the reserved characters in XML. This patch adds an 'ast_xml_escape' function, which works similarly to 'ast_uri_encode'. This is used to properly escape the local_display attribute in XML formatted NOTIFY messages. Several things to note: * The Right Thing(TM) to do would probably be to replace the ast_build_string stuff with building an ast_xml_doc. That's a much bigger change, and out of scope for the original ticket, so I refrained myself. * It is with great sadness that I wrote my own ast_xml_escape function. There's one in libxml2, but it's knee-deep in libxml2-ness, and not easily used to one-off escape a string. * I only escaped the string we know is causing problems (local_display). At least some of the other strings are URI-encoded, which should be XML safe. Rather than figuring out what's safe and escaping what's not, it would be much cleaner to simply build an ast_xml_doc for the messages and let the XML library do the XML escaping. Like I said, that's out of scope. (closes issue ABE-2902) Reported by: Guenther Kelleter Tested by: Guenther Kelleter Review: http://reviewboard.digium.internal/r/365/ ........ Merged revision 378919 from https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier ........ Merged revisions 378933 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 378934 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@378935 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-11-08Add MALLOC_DEBUG enhancements.Richard Mudgett
* Makes malloc() behave like calloc(). It will return a memory block filled with 0x55. A nonzero value. * Makes free() fill the released memory block and boundary fence's with 0xdeaddead. Any pointer use after free is going to have a pointer pointing to 0xdeaddead. The 0xdeaddead pointer is usually an invalid memory address so a crash is expected. * Puts the freed memory block into a circular array so it is not reused immediately. * When the circular array rotates out a memory block to the heap it checks that the memory has not been altered from 0xdeaddead. * Made the astmm_log message wording better. * Made crash if the DO_CRASH menuselect option is enabled and something is found. * Fixed a potential alignment issue on 64 bit systems. struct ast_region.data[] should now be aligned correctly for all platforms. * Extracted region_check_fences() from __ast_free_region() and handle_memory_show(). * Updated handle_memory_show() CLI usage help. Review: https://reviewboard.asterisk.org/r/2182/ ........ Merged revisions 376029 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 376030 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 376048 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@376049 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-18Add -fnested-functions compile flag, if needed.David M. Lee
In order to use nested functions on some versions of GCC (e.g. GCC on OS X), the -fnested-functions flag must be passed to the compiler. This patch adds detection logic to ./configure to add the flag if necessary. It also adds a comment to utils.h as to why the nested function needs a prototype. (closes issue ASTERISK-20399) Reported by: David M. Lee Review: https://reviewboard.asterisk.org/r/2102/ ........ Merged revisions 373119 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-08-30Clean up doxygen warningsMatthew Jordan
This patch fixes numerous doxygen warnings across Asterisk. It also updates the makefile to regenerate the doxygen configuration on the local system before running doxygen to help prevent warnings/errors on the local system. Much thanks to Andrew for tackling one of the Asterisk janitor projects! (issue ASTERISK-20259) Reported by: Andrew Latham Patches: doxygen_partial.diff uploaded by Andrew Latham (license 5985) make_progdocs.diff uploaded by Andrew Latham (license 5985) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371989 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-31Clean up and ensure proper usage of alloca()Kinsey Moore
This replaces all calls to alloca() with ast_alloca() which calls gcc's __builtin_alloca() to avoid BSD semantics and removes all NULL checks on memory allocated via ast_alloca() and ast_strdupa(). (closes issue ASTERISK-20125) Review: https://reviewboard.asterisk.org/r/2032/ Patch-by: Walter Doekes (wdoekes) ........ Merged revisions 370642 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 370643 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-05Tweak some comments and whitespace in utils.hRichard Mudgett
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369666 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-02Add res_http_websocket module which implements the WebSocket protocol ↵Joshua Colp
according to RFC 6455. Review: https://reviewboard.asterisk.org/r/1952/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368359 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-01Add new config-parsing frameworkTerry Wilson
This framework adds a way to register the various options in a config file with Asterisk and to handle loading and reloading of that config in a consistent and atomic manner. Review: https://reviewboard.asterisk.org/r/1873/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368181 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-22Adds F option to Bridge applicationJonathan Rose
Similar to dial and queue F option. (Closes issue ASTERISK-19282) Reported by: To Patches: bridge_f-v3.diff uploaded by To (license 6347) Review: https://reviewboard.asterisk.org/r/1825/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360227 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-29Opaquify ast_channel structs and listsTerry Wilson
Review: https://reviewboard.asterisk.org/r/1773/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357542 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-11-11Use __alignof__ instead of sizeof for stringfield length storage.Walter Doekes
Kevin P Fleming suggested that r343157 should use __alignof__ instead of sizeof. For most systems this won't be an issue, but better fix it now while it's still fresh. Review: https://reviewboard.asterisk.org/r/1573 ........ Merged revisions 344843 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 344845 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@344846 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-11-02Ensure that string field lengths are properly alignedWalter Doekes
Integers should always be aligned. For some platforms (ARM, SPARC) this is more important than for others. This changeset ensures that the string field string lengths are aligned on *all* platforms, not just on the SPARC for which there was a workaround. It also fixes that the length integer can be resized to 32 bits without problems if needed. (closes issue ASTERISK-17310) Reported by: radael, S Adrian Reviewed by: Tzafrir Cohen, Terry Wilson Tested by: S Adrian Review: https://reviewboard.asterisk.org/r/1549 ........ Merged revisions 343157 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 343158 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@343163 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-06-15Merged revisions 323863 via svnmerge from Terry Wilson
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r323863 | twilson | 2011-06-15 14:58:18 -0500 (Wed, 15 Jun 2011) | 2 lines Make ARRAY_LEN() return the same type on x86 and x86_64 systems ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@323864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-24According to section 19.1.2 of RFC 3261:Matthew Nicholson
For each component, the set of valid BNF expansions defines exactly which characters may appear unescaped. All other characters MUST be escaped. This patch modifies ast_uri_encode() to encode strings in line with this recommendation. This patch also adds an ast_escape_quoted() function which escapes '"' and '\' characters in quoted strings in accordance with section 25.1 of RFC 3261. The ast_uri_encode() function has also been modified to take an ast_flags struct describing the set of rules it should use when escaping characters to allow for it to escape SIP URIs in addition to HTTP URIs and other types of URIs or variations of those two URI types in the future. The ast_uri_decode() function has also been modified to accept an ast_flags struct describing the set of rules to use when decoding to enable decoding '+' as ' ' in legacy http URLs. The unit tests for these functions have also been updated. ABE-2705 Review: https://reviewboard.asterisk.org/r/1081/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@303509 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-12-18Merged revisions 298960 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r298960 | tilghman | 2010-12-17 17:52:04 -0600 (Fri, 17 Dec 2010) | 20 lines Merged revisions 298957 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ................ r298957 | tilghman | 2010-12-17 17:30:55 -0600 (Fri, 17 Dec 2010) | 13 lines Merged revisions 298905 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r298905 | tilghman | 2010-12-17 15:40:56 -0600 (Fri, 17 Dec 2010) | 6 lines Let Asterisk find better backtrace information with libbfd. The menuselect option BETTER_BACKTRACES, if enabled, will use libbfd to search for better symbol information within both the Asterisk binary, as well as loaded modules, to assist when using inline backtraces to track down problems. Review: https://reviewboard.asterisk.org/r/1055/ ........ ................ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@298961 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-12-12Add support for several platforms to obtain the real thread ID.Jeff Peeler
Already had the pthread ID which is not the same. The most obvious enhancement is in the "core show threads" output. As stated in the utils header, if the platform isn't supported -1 is reported (instead of the process ID previously). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@298137 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-09Various updates to the unit test API.Russell Bryant
1) It occurred to me that the difference in usage between the error ast_str and the ast_test_update_status() usage has turned out to be a bit ambiguous in practice. In a lot of cases, the same message was being sent to both. In other cases, it was only sent to one or the other. My opinion now is that in every case, I think it makes sense to do both; we should output it to the CLI as well as save it off for logging purposes. This change results in most of the changes in this diff, since it required changes to all existing unit tests. It also allowed for some simplifications of unit test API implementation code. 2) Update ast_test_status_update() to include the file, function, and line number for the code providing the update. 3) There are some formatting tweaks here and there. Hopefully they aren't too distracting for code review purposes. Reviewboard's diff viewer seems to do a pretty good job of pointing out when something is a whitespace change. 4) I moved the md5_test and sha1_test into the test_utils module. It seemed like a better approach since these tests are so tiny. 5) I changed the number of nodes used in heap_test_2 from 1 million to 100 thousand. The only reason for this was to reduce the time it took for this test to run. 6) Remove an unused function prototype that was at the bottom of utils.h. 7) Simplify test_insert() using the LIST_INSERT_SORTALPHA() macro. The one minor difference in behavior is that it no longer checks for a test registered with the same name. 8) Expand the code in test_alloc() to provide specific error messages for each failure case, to clearly inform developers if they forget to set the name, summary, description, etc. 9) Tweak the output of the "test show registered" CLI command. I swapped the name and category to have the category first. It seemed more natural since that is the sort key. 10) Don't output the status ast_str in the "test show results" CLI command. This is going to tend to be pretty verbose, so just leave that for the detailed test logs (test generate results). Review: https://reviewboard.asterisk.org/r/493/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-26RFC compliant uri and display-name encode/decodeDavid Vossel
1. URI Encoding This patch changes ast_uri_encode()'s behavior when doreserved is enabled. Previously when doreserved was enabled only a small set of reserved characters were encoded. This set was comprised primarily of the reserved characters defined in RFC3261 section 25.1, but contained other characters as well. Rather than only escaping the reserved set, doreserved now escapes all characters not within the unreserved set as defined by RFC 3261 and RFC 2396. Also, the 'doreserved' variable has been renamed to 'do_special_char' in attempts to avoid confusion. When doreserve is not enabled, the previous logic of only encoding the characters <= 0X1F and > 0X7f remains, except for the '%' character, which must always be encoded as it signifies a HEX escaped character during the decode process. 2. URI Decoding: Break up URI before decode. In chan_sip.c ast_uri_decode is called on the entire URI instead of it's individual parts after it is parsed. This is not good as ast_uri_decode can introduce special characters back into the URI which can mess up parsing. This patch resolves this by not decoding a URI until parsing is completely done. There are many instances where we check to see if pedantic checking is enabled before we decode a URI. In these cases a new macro, SIP_PEDANTIC_DECODE, is used on the individual parsed segments of the URI rather than constantly putting if (pedantic) { decode() } checks everywhere in the code. In the areas where ast_uri_decode is not dependent upon pedantic checking this macro is not used, but decoding is still moved to each individual part of the URI. The only behavior that should change from this patch is the time at which decoding occurs. Since I had to look over every place URI parsing occurs to create this patch, I found several places where we use duplicate code for parsing. To consolidate the code, those areas have updated to use the parse_uri() function where possible. 3. SIP display-name decoding according to RFC3261 section 25. To properly decode the display-name portion of a FROM header, chan_sip's get_calleridname() function required a complete re-write. More information about this change can be found in the comments at the beginning of this function. 4. Unit Tests. Unit tests for ast_uri_encode, ast_uri_decode, and get_calleridname() have been written. This involved the addition of the test_utils.c file for testing the utils api. (closes issue #16299) Reported by: wdoekes Patches: astsvn-16299-get_calleridname.diff uploaded by wdoekes (license 717) get_calleridname_rewrite.diff uploaded by dvossel (license 671) Tested by: wdoekes, dvossel, Nick_Lewis Review: https://reviewboard.asterisk.org/r/469/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243200 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-07-28Define side-effect-safe MIN and MAX macros and remove duplicate definitions ↵Kevin P. Fleming
from various files. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@209400 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-26Merge the new Channel Event Logging (CEL) subsystem.Russell Bryant
CEL is the new system for logging channel events. This was inspired after facing many problems trying to represent what is possible to happen to a call in Asterisk using CDR records. For more information on CEL, see the built in HTML or PDF documentation generated from the files in doc/tex/. Many thanks to Steve Murphy (murf) and Brian Degenhardt (bmd) for their hard work developing this code. Also, thanks to Matt Nicholson (mnicholson) and Sean Bright (seanbright) for their assistance in the final push to get this code ready for Asterisk trunk. Review: https://reviewboard.asterisk.org/r/239/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@203638 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-10Merged revisions 199856 via svnmerge from Sean Bright
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r199856 | seanbright | 2009-06-10 12:08:35 -0400 (Wed, 10 Jun 2009) | 2 lines __WORDSIZE is not available on all platforms, so use sizeof(void *) instead. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@199857 65c4cc65-6c06-0410-ace0-fbb531ad65f3