Commit Graph

39 Commits

Author SHA1 Message Date
Jaco Kroon 44e5dd288b Remove #include <sys/cdefs.h>
These are not provided by standards, and as a result causes failure to
compile on musl.

https://wiki.musl-libc.org/faq.html#Q:-When-compiling-something-against-musl,-I-get-error-messages-about-%3Ccode%3Esys/cdefs.h%3C/code%3E

Change-Id: I6a357cefd106c72cfecafd898638f6b5692c2e05
2020-05-05 10:06:43 -05:00
Sean Bright fd0ca1c3f9 Remove as much trailing whitespace as possible.
Change-Id: I873c1c6d00f447269bd841494459efccdd2c19c0
2017-12-22 09:23:22 -05:00
Corey Farrell 58d032112b Fix compiler warnings on Fedora 26 / GCC 7.
GCC 7 has added capability to produce warnings, this fixes most of those
warnings.  The specific warnings are disabled in a few places:

* app_voicemail.c: truncation of paths more than 4096 chars in many places.
* chan_mgcp.c: callid truncated to 80 chars.
* cdr.c: two userfields are combined to cdr copy, fix would break ABI.
* tcptls.c: ignore use of deprecated method SSLv3_client_method().

ASTERISK-27156 #close

Change-Id: I65f280e7d3cfad279d16f41823a4d6fddcbc4c88
2017-08-01 15:42:38 -06:00
Corey Farrell a6e5bae3ef Remove ASTERISK_REGISTER_FILE.
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes
all traces of it.

Previously exported symbols removed:
* __ast_register_file
* __ast_unregister_file
* ast_complete_source_filename

This also removes the mtx_prof static variable that was declared when
MTX_PROFILE was enabled.  This variable was only used in lock.c so it
is now initialized in that file only.

ASTERISK-26480 #close

Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
2016-10-27 09:53:55 -04:00
Richard Mudgett 44f16af7cc ast_expr2: Fix off-nominal memory leak.
Thanks to ibercom for pointing out a memory leak that was missed
in the earlier patch for the issue.

ASTERISK-26119
Reported by: Alexei Gradinari

Change-Id: I9a151f5c4725d97fb82a9e938bc73dc659532b71
2016-07-11 13:51:29 -05:00
Alexei Gradinari 820ed3d4b3 fix: memory leaks, resource leaks, out of bounds and bugs
ASTERISK-26119 #close

Change-Id: Iecbf7d0f360a021147344c4e83ab242fd1e7512c
2016-06-20 13:08:18 -04:00
Timo Teräs 9c1d95e873 Fix #include poll.h and sys/cdefs.h
POSIX defines poll.h, sys/poll.h should not be used at is c-library
internal header which may or may not exist. Notable in musl it
generates warning of being incorrect. And add explict include of
sys/cdefs.h where needed.

Change-Id: I142930df53fe7585a06b854b6faddc5301e024be
2016-06-02 22:53:39 +03:00
Corey Farrell 478fb4a388 MALLOC_DEBUG: Replace WRAP_LIBC_MALLOC with ASTMM_LIBC.
There are 3 ways that calls directly to standard allocator functions can
be dealt with:
1. Block their use, cause them to generate an error.  This is the default.
2. Replace them with the Asterisk equivalent function calls.
3. Leave them alone.

This change allows one of these 3 options to be selected by any source.
The source just needs to define ASTMM_LIBC to ASTMM_BLOCK, ASTMM_REDIRECT,
or ASTMM_IGNORE to use option 1, 2 or 3 respectively.  Normally ASTMM_BLOCK
is the correct option, so it is default when ASTMM_LIBC is not defined.
In some cases when building 3rd party code it is desirable to have it use
Asterisk functions, without changing the whole source - ASTMM_REDIRECT
accomplishes this.  When using 3rd party libraries sometimes a static
inline function will make use of malloc or free.  In these cases it may
be unsafe to replace the allocator in the header, as it's possible the
memory could be freed by the library using standard allocators.  For
those cases ASTMM_IGNORE is needed.

Change-Id: I8afef4bc7f3b93914263ae27d3a5858b69663fc7
2015-05-13 21:55:07 -04:00
Matt Jordan 4a58261694 git migration: Refactor the ASTERISK_FILE_VERSION macro
Git does not support the ability to replace a token with a version
string during check-in. While it does have support for replacing a
token on clone, this is somewhat sub-optimal: the token is replaced
with the object hash, which is not particularly easy for human
consumption. What's more, in practice, the source file version was often
not terribly useful. Generally, when triaging bugs, the overall version
of Asterisk is far more useful than an individual SVN version of a file. As a
result, this patch removes Asterisk's support for showing source file
versions.

Specifically, it does the following:

* Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and
  remove passing the version in with the macro. Other facilities
  than 'core show file version' make use of the file names, such as
  setting a debug level only on a specific file. As such, the act of
  registering source files with the Asterisk core still has use. The
  macro rename now reflects the new macro purpose.

* main/asterisk:
  - Refactor the file_version structure to reflect that it no longer
    tracks a version field.
  - Remove the "core show file version" CLI command. Without the file
    version, it is no longer useful.
  - Remove the ast_file_version_find function. The file version is no
    longer tracked.
  - Rename ast_register_file_version/ast_unregister_file_version to
    ast_register_file/ast_unregister_file, respectively.

* main/manager: Remove value from the Version key of the ModuleCheck
  Action. The actual key itself has not been removed, as doing so would
  absolutely constitute a backwards incompatible change. However, since
  the file version is no longer tracked, there is no need to attempt to
  include it in the Version key.

* UPGRADE: Add notes for:
  - Modification to the ModuleCheck AMI Action
  - Removal of the "core show file version" CLI command

Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
2015-04-13 03:48:57 -04:00
Walter Doekes 37179a2b1f core: Don't allow free to mean ast_free (and malloc, etc..).
This gets rid of most old libc free/malloc/realloc and replaces them
with ast_free and friends. When compiling with MALLOC_DEBUG you'll
notice it when you're mistakenly using one of the libc variants. For
the legacy cases you can define WRAP_LIBC_MALLOC before including
asterisk.h.

Even better would be if the errors were also enabled when compiling
without MALLOC_DEBUG, but that's a slightly more invasive header
file change.

Those compiling addons/format_mp3 will need to rerun
./contrib/scripts/get_mp3_source.sh.

ASTERISK-24348 #related
Review: https://reviewboard.asterisk.org/r/4015/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423978 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-26 14:41:38 +00:00
Tilghman Lesher 6190ae4430 Allow the REALTIME() function to report errors back to the caller.
Also, do more error checking on the arguments specified to the REALTIME()
function and clarify the documentation.  While I was editing the file, a
few coding guidelines fixups, as well.

Review: https://reviewboard.asterisk.org/r/2031/
........

Merged revisions 369937 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 369938 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369940 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-11 17:16:50 +00:00
Russell Bryant cad07b3800 Multiple revisions 360356-360357
........
  r360356 | russell | 2012-03-23 22:33:36 -0400 (Fri, 23 Mar 2012) | 6 lines
  
  expression parser: Fix (theoretical) memory leak.
  
  Fix a memory leak that is very unlikely to actually happen.  If a malloc()
  succeeded, but the following strdup() failed, the memory from the original
  malloc() would be leaked.
........
  r360357 | russell | 2012-03-23 22:34:39 -0400 (Fri, 23 Mar 2012) | 6 lines
  
  Rebuild parsers.
  
  This is needed to include the last fix to main/ast_expr2.y.  The changes look
  much bigger as this regeneration of the code was done with newer versions of
  flex and bison.
........

Merged revisions 360356-360357 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 360358 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360359 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-03-24 02:42:42 +00:00
Tilghman Lesher c60d15222c Add ABS() absolute value function to the expression parser.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@351079 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-01-16 19:49:50 +00:00
Tilghman Lesher d07eca63b6 Merged revisions 293197 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r293197 | tilghman | 2010-10-28 15:00:06 -0500 (Thu, 28 Oct 2010) | 33 lines
  
  Merged revisions 293195-293196 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ................
    r293195 | tilghman | 2010-10-28 14:52:52 -0500 (Thu, 28 Oct 2010) | 12 lines
    
    Merged revisions 293194 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r293194 | tilghman | 2010-10-28 14:44:37 -0500 (Thu, 28 Oct 2010) | 5 lines
      
      "!00" evaluated as false, which is incorrect.  Fixing.
      
      Reported (though the reporter did not understand he was reporting a bug) on the asterisk-users list:
      http://lists.digium.com/pipermail/asterisk-users/2010-October/255505.html
    ........
  ................
    r293196 | tilghman | 2010-10-28 14:54:34 -0500 (Thu, 28 Oct 2010) | 12 lines
    
    Merged revisions 293194 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r293194 | tilghman | 2010-10-28 14:44:37 -0500 (Thu, 28 Oct 2010) | 5 lines
      
      "!00" evaluated as false, which is incorrect.  Fixing.
      
      Reported (though the reporter did not understand he was reporting a bug) on the asterisk-users list:
      http://lists.digium.com/pipermail/asterisk-users/2010-October/255505.html
    ........
  ................
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@293198 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-10-28 20:01:28 +00:00
Jason Parker 21954cea7d Allow "REMAINDER" to function properly in expressions.
(closes issue #16427)
Reported by: wdoekes
Patches:
      ast16-reminder-remainder.patch uploaded by wdoekes (license 717)
Tested by: wdoekes


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@236713 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-28 22:09:40 +00:00
David Vossel a6426cdf9d fixes a few redundant conditions
(issue #15269)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@203444 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-25 21:45:32 +00:00
David Vossel dcfe69ec64 fixes some memory leaks and redundant conditions
(closes issue #15269)
Reported by: contactmayankjain
Patches:
      patch.txt uploaded by contactmayankjain (license 740)
      memory_leak_stuff.trunk.diff uploaded by dvossel (license 671)
Tested by: contactmayankjain, dvossel




git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@201678 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-18 16:37:42 +00:00
Steve Murphy f47b03877b Merged revisions 179807 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

I had some work to do to port these changes to trunk; the 
check_expr stuff hasn't been updated here for quite some
time, it appears. I added some more tests to the check_expr2
suite. I had to play around with the makefile a bit, etc.

I added STANDALONE2 #ifdefs to ast_expr2.y so as not to
conflict structure with aelparse.

........
  r179807 | murf | 2009-03-03 11:11:34 -0700 (Tue, 03 Mar 2009) | 19 lines
  
  These changes allow AEL to better check ${} constructs within $[...], that are concatenated with text.
  
  I modified and added rules in ast_expr2.fl to better handle
  the concatenations.
  
  I added some default routines to ast_expr2.y so the standalone would
  compile. It also looks like I haven't run this thru bison since 2.1, so
  it's good to get this updated.
  
  The Makefile has comments added now for check_expr2 and check_expr to
  explain what they are for, and how to run them. 
  
  The testexpr2s stuff has been removed, in favor of check_expr2.
  
  expr2.testinput has been updated to include the two expressions
  that inspired these changes (from mcnobody on #asterisk this morning)
  The regression has been run and all looks well.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@179973 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-03 22:12:02 +00:00
Steve Murphy 2fb28891a3 This patch allows null args in ast_expr2 func calls, and fixes commas being converted to pipes, which was 1.4 type stuff.
If the user says count=ENUMLOOKUP(${EXTEN},ALL,c,,enum.mydomain.tld);

then it won't complain about the empty arg (c,,...) and fabled's patch
won't let it swap the commas for pipes.

Ran it thru my dialplan and no complaints.


(closes issue #14169)
Reported by: fabled
Patches:
      function-argument-separator-fix.diff uploaded by fabled (license 448)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@168737 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-01-15 20:54:59 +00:00
Tilghman Lesher dca80878af That was weird...
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@166958 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-12-31 19:39:05 +00:00
Tilghman Lesher 7cb7920e19 Merged revisions 166953 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r166953 | tilghman | 2008-12-31 13:20:35 -0600 (Wed, 31 Dec 2008) | 5 lines
  
  Also inherit the musiconhold class.
  (Closes #14153)
  Reported by: Jerry Geis, via the users list.
  Patch by: me (license 14)
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@166954 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-12-31 19:34:28 +00:00
Kevin P. Fleming 887e28d7aa incorporates r159808 from branches/1.4:
------------------------------------------------------------------------
r159808 | kpfleming | 2008-11-29 10:58:29 -0600 (Sat, 29 Nov 2008) | 7 lines

update dev-mode compiler flags to match the ones used by default on Ubuntu Intrepid, so all developers will see the same warnings and errors

since this branch already had some printf format attributes, enable checking for them and tag functions that didn't have them

format attributes in a consistent way


------------------------------------------------------------------------

in addition:

move some format attributes from main/utils.c to the header files they belong in, and fix up references to the relevant functions based on new compiler warnings



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@159818 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-11-29 17:57:39 +00:00
Kevin P. Fleming 629861a705 Merged revisions 144924-144925 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r144924 | kpfleming | 2008-09-27 10:00:48 -0500 (Sat, 27 Sep 2008) | 6 lines
  
  improve header inclusion process in a few small ways:
  
    - it is no longer necessary to forcibly include asterisk/autoconfig.h; every module already includes asterisk.h as its first header (even before system headers), which serves the same purpose
    - astmm.h is now included by asterisk.h when needed, instead of being forced by the Makefile; this means external modules will build properly against installed headers with MALLOC_DEBUG enabled
    - simplify the usage of some of these headers in the AEL-related stuff in the utils directory
........
  r144925 | kpfleming | 2008-09-27 10:13:30 -0500 (Sat, 27 Sep 2008) | 2 lines
  
  fix some minor issues with rev 144924
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@144949 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-09-27 15:52:56 +00:00
Steve Murphy c0b8f57b9d (closes issue #12467)
Reported by: atis
Tested by: murf

This upgrade adds the ~~ (concatenation) string operator to expr2.
While not needed in normal runtime pbx operation, it is needed when
raw exprs are being syntax checked. This plays into future syntax-
unification plans. By permission of atis, this addition in trunk 
and the reason of why things are as they are will suffice to close
this bug.

I also added a short note about the previous addition of "sip show sched"
to the CLI in CHANGES, which I discovered I forgot in a previous commit.




git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-21 21:13:02 +00:00
Steve Murphy 241de02854 Terry found this problem with running the expr2 parser on OSX. Make the #defines come out the same between the parser & lexer.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@98953 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-16 01:35:10 +00:00
Steve Murphy 16d06cb62f closes issue #11045 - each file needs to define ASTERISK_FILE_VERSION, if you are going to set MTX_PROFILE in the compiler flags; the problem was that the fixes were getting made to the generated .c file, and erased the next time someone regenerated that file from the corresponding .y or .flex file. Moral of story: keep your eyes open and make mods to the .y (or flex input file) and re-run bison (or flex) as the Makefile directs for that file, and then check in both. Also, res_config_sqlite was kinda missed, and has the same issue.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@87024 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-25 16:21:30 +00:00
Tilghman Lesher 727a908023 Simplify some preprocessor logic by using #elif
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@86197 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-17 21:16:40 +00:00
Joshua Colp 648f67d4c8 Fix up tree so that it compiles when MTX Profiling is enabled.
(closes issue #10898)
Reported by: snuffy
Patches:
      10898-mtx_prof.diff uploaded by qwell (license 4)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85025 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-08 16:12:21 +00:00
Tilghman Lesher 48f56ba8b4 Fixes for FreeBSD... testing for every conceivable math function now
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@83517 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-09-22 02:07:53 +00:00
Tilghman Lesher 78a94595f6 Check for the presence of trunc and round, and make the ISOC99 detection a little more sane (closes issue #10776)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@83431 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-09-21 14:25:51 +00:00
Tilghman Lesher 935bd057f8 Restore EXP2 and LOG2 functions, by providing mathematical identify functions, when the underlying C functions are not available.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@73911 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-08 21:01:28 +00:00
Steve Murphy 1827bcba77 These changes fix 10145 and 10150, a prob with BSD and exp2/log2 not existing, as well as the bootstrap needing a small upgrade for openbsd. Many thanks to mvanbaak
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@73821 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-07 16:44:57 +00:00
Russell Bryant 2b0ec81639 resolve a compiler warning so i can build in dev mode
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@73514 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-05 20:52:29 +00:00
Steve Murphy 6a4efe5d5a In regards to changes for 9508, expr2 system choking on floating point numbers, I'm adding this update to round out (no pun intended) and make this FP-capable version of the Expr2 stuff interoperate better with previous integer-only usage, by providing Functions syntax, with 20 builtin functions for floating pt to integer conversions, and some general floating point math routines that might commonly be used also. Along with this, I made it so if a function was not a builtin, it will try and find it in the ast_custom_function list, and if found, execute it and collect the results. Thus, you can call system functions like CDR(), CHANNEL(), etc, from within $\[..\] exprs, without having to wrap them in $\{...\} (curly brace) notation. Did a valgrind on the standalone and made sure there's no mem leaks. Looks good. Updated the docs, too.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@73449 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-05 18:15:22 +00:00
Steve Murphy 94b934c8f6 Merged revisions 72933 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r72933 | murf | 2007-07-02 14:16:31 -0600 (Mon, 02 Jul 2007) | 1 line

support for floating point numbers added to ast_expr2 $\[...\] exprs. Fixes bug 9508, where the expr code fails with fp numbers. The MATH function returns fp numbers by default, so this fix is considered necessary.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@72940 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-02 21:50:15 +00:00
Kevin P. Fleming 74f31a51bc add -Wundef to the --enable-dev-mode flags, so that mistyped macro names in #if expressions will be caught
convert various #if expressions to #ifdef for macros that may not be defined (and where the value is not important)
Note: two of these changes are in bison generated files which is going to be inconvenient when they are regenerated


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@55329 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-02-18 15:03:42 +00:00
Steve Murphy 6c7f4c1e32 Jason is having problems with the inclusion of <err.h>; it appears to be unnecessary for sucessful builds, so I either removed or commented out the inclusions from all the AEL related code. New outputs from bison/flex are included, etc.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49019 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-28 17:56:21 +00:00
Kevin P. Fleming 696f9ed677 Merged revisions 45408 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r45408 | kpfleming | 2006-10-17 17:24:10 -0500 (Tue, 17 Oct 2006) | 3 lines

optimize the 'quick response' code a bit more... no more malloc() or memset() for each response
expand stringfields API a bit to allow reusing the stringfield pool on a structure when needed, and remove some unnecessary code when the structure was being freed

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45409 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 22:24:45 +00:00
Kevin P. Fleming 0a27d8bfe5 merge new_loader_completion branch, including (at least):
- restructured build tree and makefiles to eliminate recursion problems
  - support for embedded modules
  - support for static builds
  - simpler cross-compilation support
  - simpler module/loader interface (no exported symbols)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@40722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-08-21 02:11:39 +00:00