summaryrefslogtreecommitdiff
path: root/cel/cel_pgsql.c
AgeCommit message (Collapse)Author
2017-03-30cdr_pgsql: Fix buffer overflow calling libpqSean Bright
Implement the same buffer size checking done in cel_pgsql. ASTERISK-26896 #close Reported by: twisted Change-Id: Iaacfa1f1de7cb1e9414d121850d2d8c2888f3f48
2017-03-29cel_pgsql.c: Fix buffer overflow calling libpqJosh Roberson
PQEscapeStringConn() expects the buffer passed in to be an adequitely sized buffer to write out the escaped SQL value string into. It is possible, for large values (such as large values to Dial with a lot of devices) to have more than our 512+1 byte allocation and thus cause libpq to create a buffer overrun. glibc will nicely ABRT asterisk for you, citing a stack smash. Let's only allocate it to be as large as needed: If we have a value, then (strlen(value) * 2) + 1 (as recommended by libpq), and if we have none, just one byte to hold our null will do. ASTERISK-26896 #close Change-Id: If611c734292618ed68dde17816d09dd16667dea2
2016-10-27Remove ASTERISK_REGISTER_FILE.Corey Farrell
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
2015-09-18dr_adaptive_odbc.c, cel_odbc.c, cel_pgsql.c: REFACTOR Macro LENGTHEN_BUFRodrigo Ramírez Norambuena
Remove repeated code on macro of assigned buffer to SQL vars Change-Id: Icb19ad013124498e172ea1d0b29ccd0ed17deef0
2015-05-14Merge "cel/cel_pgsql.c: Use the 'SEP' macro when appending a column name"Joshua Colp
2015-05-13cel/cel_pgsql.c: Use the 'SEP' macro when appending a column nameRodrigo Ramírez Norambuena
When appending a column name to the sql buffer, the predicate, "if first is non-null, use empty string; else, use comma", is identical to the 'SEP' macro definition. Since they are the same, this patch replaces the redundant predicate statement with the 'SEP' macro. Change-Id: Ib8b6138b06a48381723108a05ab8752cb8700509
2015-05-13Merge "cdr_pgsql, cel_pgsql: Store maximum buffer size to prevent reallocation"Joshua Colp
2015-05-12cdr_pgsql, cel_pgsql: Store maximum buffer size to prevent reallocationRodrigo Ramírez Norambuena
The code previously used a fixed size of 512 for the SQL queries. Depending on the size this may require it to grow. This change makes it so if the buffer size does grow the size is stored and next time the buffer will be large enough. Change-Id: I55385899f1c06dee47e4274c2d21538037b2d895
2015-05-05cel_pgsql: Add support for setting schemaRodrigo Ramírez Norambuena
Add feature to set optional schema parameter on configuration file via 'schema' setting. Fix query to get columns from table while considering schema. If in the database there exists two tables with same name in distinct schemas it will return an error when inserting record. ASTERISK-24967 #close Change-Id: I691fd2cbc277fcba10e615f5884f8de5d8152f2c
2015-04-15cel_pgsql: Fix name string for log on unable allocate memory.Rodrigo Ramírez Norambuena
The LOG_ERROR has reference to CDR instead of CEL for LENGTHEN_BUF1 and LENGTHEN_BUF2. ASTERISK-24965 #close Reported by: Rodrigo Ramirez Norambuena Change-Id: Icc818697d7d66d34bfe3048cdd15ca2b06c89744
2015-04-13git migration: Refactor the ASTERISK_FILE_VERSION macroMatt Jordan
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-08cel_pgsl: Add support for GMT timestampsMatthew Jordan
This patch adds a new option to cel_pgsl, "usegmtime", which causes timestamps to be logged in GMT. Review: https://reviewboard.asterisk.org/r/4571/ ASTERISK-23186 #close Reported by: Rodrigo Ramirez Norambuena patches: cel_pgsql.c_add_usegmtime2.patch submitted by Rodrigo Ramirez Norambuena (License 6577) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434284 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-25Add module support level to ast_module_info structure. Print it in CLI ↵Mark Michelson
"module show" . ASTERISK-23919 #close Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/3802 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419592 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-16cel_pgsql, cdr_pgsql, res_config_pgsql: Add PostgreSQL application_name supportMatthew Jordan
This patch adds support for the PostgreSQL application_name connection setting. When the appropriate PostgreSQL module's configuration is set with an application name, the name will be passed to PostgreSQL on connection and displayed in the database's pg_stat_activity view, as well as in CSV logs. This aids in managing which applications/servers are connected to a PostgreSQL database, as well as tracing the activity of those connections. Review: https://reviewboard.asterisk.org/r/3591 ASTERISK-23737 #close Reported by: Gergely Domodi patches: pgsql_application_name.patch uploaded by Gergely Domodi (License 6610) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418755 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-28Logger/CLI/etc.: Fix some aesthetic issues; reduce chatty verbose messagesMatthew Jordan
This patch addresses some aesthetic issues in Asterisk. These are all just minor tweaks to improve the look of the CLI when used in a variety of settings. Specifically: * A number of chatty verbose messages were removed or demoted to DEBUG messages. Verbose messages with a verbosity level of 5 or higher were - if kept as verbose messages - demoted to level 4. Several messages that were emitted at verbose level 3 were demoted to 4, as announcement of dialplan applications being executed occur at level 3 (and so the effects of those applications should generally be less). * Some verbose messages that only appear when their respective 'debug' options are enabled were bumped up to always be displayed. * Prefix/timestamping of verbose messages were moved to the verboser handlers. This was done to prevent duplication of prefixes when the timestamp option (-T) is used with the CLI. * Verbose magic is removed from messages before being emitted to non-verboser handlers. This prevents the magic in multi-line verbose messages (such as SIP debug traces or the output of DumpChan) from being written to files. * _Slightly_ better support for the "light background" option (-W) was added. This includes using ast_term_quit in the output of XML documentation help, as well as changing the "Asterisk Ready" prompt to bright green on the default background (which stands a better chance of being displayed properly than bright white). Review: https://reviewboard.asterisk.org/r/3547/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414798 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-09Allow Asterisk to compile under GCC 4.10Kinsey Moore
This resolves a large number of compiler warnings from GCC 4.10 which cause the build to fail under dev mode. The vast majority are signed/unsigned mismatches in printf-style format strings. ........ Merged revisions 413586 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 413587 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 413588 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413589 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-03cel_pgsql: module not correctly reloadingKevin Harwell
Upon reload the module unconditionally "unloaded" the module (freeing memory and setting pointers to NULL) and then when attempting a "load" if the config file had not changed then nothing would be reinitialized. By moving the "unload" to occur conditionally (reload only) after an attempted configuration load, but before module "loading" alleviates the issue. The module now loads/unloads/reloads correctly. (closes issue ASTERISK-22871) Reported by: Matteo ........ Merged revisions 404857 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 404858 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 404859 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404860 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-12-31cel_pgsql: deadlock on unload and core_event_dispatcherKevin Harwell
A deadlock can happen between a thread unloading or reloading the cel_pgsql module and the core_event_dispatcher taskprocessor thread. Description of what is happening: Thread 1 (for example, a netconsole thread): a "module reload cel_pgsql" is launched the thread enter the "my_unload_module" function (cel_pgsql.c) the thread acquire the write lock on psql_columns the thread enter the "ast_event_unsubscribe" function (event.c) the thread try to acquire the write lock on ast_event_subs[sub->type] Thread 2 (core_event_dispatcher taskprocessor thread): the taskprocessor pop a CEL event the thread enter the "handle_event" function (event.c) the thread acquire the read lock on ast_event_subs[sub->type] the thread callback the "pgsql_log" function (cel_pgsql.c), since it's a subscriber of CEL events the thread try to acquire a read lock on psql_columns (closes issue ASTERISK-22854) Reported by: Etienne Lessard Patches: cel_pgsql_fix_deadlock_event.patch uploaded by hexanol (license 6394) ........ Merged revisions 404603 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 404604 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 404605 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404606 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-17Refactor CEL to avoid using the event system coreKinsey Moore
This removes usage of the event system for CEL backend data distribution and strips unused pieces out of the event system. Review: https://reviewboard.asterisk.org/r/2732/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396888 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-21Doxygen Updates - janitor workAndrew Latham
Doxygen updates including mistakes, misspellings, missing parameters, updates for Doxygen style. Some missing txt file links are removed but their content or essense will be included in some later updates. A majority of the txt files were removed in the 1.6 era but never noted. The HR and EXTREF are simple changes that make the documentation more compatable with more versions of Doxygen. Further updates coming. (issue ASTERISK-20259) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373330 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-09-05Fix memory leak when CEL is successfully written to PostgreSQL databaseMatthew Jordan
PQClear is not called when the result object of a call to PQExec has a status of PGRES_COMMAND_OK. Interestingly enough, the off nominal case was handled properly, so this memory leak only occurred when CEL records were successfully written. This patch properly clears the result in the nominal code path. (closes issue ASTERISK-19991) Reported by: Etienne Lessard Tested by: Etienne Lessard patches: mem_leak_cel_pgsql.patch uploaded by Etienne Lessard (license #6394) ........ Merged revisions 372158 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 372165 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 372175 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372176 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-01Remove inconsistency in CEL eventtype for user defined events.Richard Mudgett
The CEL eventtype field for ODBC and PGSQL backends should be USER_DEFINED instead of the user defined event name supplied by the CELGenUserEvent application. If the field is output as a number, the user defined name does not have a value and is always output as 21 for USER_DEFINED and the userdeftype field would be required to supply the user defined name. The following CEL backends (cel_odbc, cel_pgsql, cel_custom, cel_manager, and cel_sqlite3_custom) can be independently configured to remove this inconsistency. * Allows cel_manager, cel_custom, and cel_sqlite3_custom to behave the same way. (closes issue ASTERISK-17189) Reported by: Bryant Zimmerman Review: https://reviewboard.asterisk.org/r/1669/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@353648 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-12-22Fix for memory leaks / cleanup in cel_pgsqlMatthew Jordan
There were a number of issues in cel_pgsql's pgsql_log method: * If either sql or sql2 could not be allocated, the method would return while the pgsql_lock was still locked * If the execution of the log statement succeeded, the sql and sql2 structs were never free'd * Reconnection successes were logged as ERRORs. In general, the severity of several logging statements was reduced (closes issue ASTERISK-18879) Reported by: Niolas Bouliane Tested by: Matt Jordan Review: https://reviewboard.asterisk.org/r/1624/ ........ Merged revisions 348888 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 348889 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@348890 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-07-14Merged revisions 328247 via svnmerge from Leif Madsen
https://origsvn.digium.com/svn/asterisk/branches/1.10 ................ r328247 | lmadsen | 2011-07-14 16:25:31 -0400 (Thu, 14 Jul 2011) | 14 lines Merged revisions 328209 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r328209 | lmadsen | 2011-07-14 16:13:06 -0400 (Thu, 14 Jul 2011) | 6 lines Introduce <support_level> tags in MODULEINFO. This change introduces MODULEINFO into many modules in Asterisk in order to show the community support level for those modules. This is used by changes committed to menuselect by Russell Bryant recently (r917 in menuselect). More information about the support level types and what they mean is available on the wiki at https://wiki.asterisk.org/wiki/display/AST/Asterisk+Module+Support+States ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@328259 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-05Add CEL extra field to cel_pgsql.Russell Bryant
(closes issue #18462) Reported by: joscas Patches: bug_18462.diff uploaded by snuffy (license 35) cel_pgsql.conf.sample.issue18462.patch uploaded by joscas (license 1180) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@317482 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-05Merged revisions 317474 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r317474 | russell | 2011-05-05 17:36:33 -0500 (Thu, 05 May 2011) | 2 lines Fix more "set but unused" warnings. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@317475 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-01Merged revisions 305603 via svnmerge from Brett Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r305603 | bbryant | 2011-02-01 14:23:20 -0500 (Tue, 01 Feb 2011) | 4 lines Add a possible solution to a customer problem with reloading cel_pgsql.so quickly. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@305604 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-20Add load priority order, such that preload becomes unnecessary in most casesTilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@278132 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-07-14Fix documentation for pgsql cel and cdr, and slightly improve pgsql_cel.Tim Ringenbach
Change the documented pgsql schema to use "timestamp" instead of "time", as the latter is only a time without a date. Added some missing columns for cel's pgsql schema, and corrected spelling on some others. Updated cel's uniqueid size to be the same as the cdr. Added id column to cel's pgsql schema and updated code to allow unknown columns to get their default value instead of forcing 0 or empty string. Added microseconds to the timestamp cel logs to pgsql. Review: https://reviewboard.asterisk.org/r/734 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@276349 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-20Resolve more compiler warnings on FreeBSD.Russell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@253540 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-10-07Use extref for doxygen references to external libraries (in this case ↵Olle Johansson
PostgreSQL) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@222614 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-08-10AST-2009-005Tilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@211539 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