]> git.ipfire.org Git - thirdparty/asterisk.git/commit
Fix potential memory allocation failure crashes in config.c.
authorRichard Mudgett <rmudgett@digium.com>
Fri, 2 Sep 2011 17:10:58 +0000 (17:10 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Fri, 2 Sep 2011 17:10:58 +0000 (17:10 +0000)
commit6d49117675ecbb228016788045c27b728598a1ed
tree5c730654ce0d47394e0bd3b676033fc961360153
parentb178214e078e6a9a985ebcece65d5066ecfc9f69
Fix potential memory allocation failure crashes in config.c.

* Added required checks to the returned memory allocation pointers to
prevent crashes.

* Made ast_include_rename() create a replacement ast_variable list node if
the new filename is longer than the available space.  Fixes potential
crash and memory leak.

* Factored out ast_variable_move() from ast_variable_update() so
ast_include_rename() can also use it when creating a replacement
ast_variable list node.

* Made the filename stuffed at the end of the struct a minimum allocated
size in ast_variable_new() in case ast_include_rename() changes the stored
filename.

* Constify struct char pointers pointing to strings stuffed at the end of
the struct for: ast_variable, cache_file_mtime, and ast_config_map.

* Factored out cfmtime_new() to remove inlined code and allow some struct
pointers to become const.

* Removed the list lock from struct cache_file_mtime that was never used.

* Added doxygen comments to several structure elements and better
documented what strings are stuffed at the struct end char array.

* Reworked ast_config_text_file_save() and set_fn() to handle allocation
failure of the include file scratch pad object tracking blank lines.

* Made ast_config_text_file_save() fn[] declared with PATH_MAX to ensure
it is long enough for any filename with path.  Also reduced the number of
container fileset buckets from a rediculus 180,000 to 1023.

JIRA AST-618

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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@334296 65c4cc65-6c06-0410-ace0-fbb531ad65f3
include/asterisk/config.h
main/config.c