Clean up and ensure proper usage of alloca()

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
This commit is contained in:
Kinsey Moore
2012-07-31 20:21:43 +00:00
parent 6c23a60f80
commit 9b16c8b0f6
64 changed files with 317 additions and 399 deletions

View File

@@ -947,7 +947,7 @@ static int control_streamfile(struct ast_channel *chan,
}
if (blen > 2) {
breaks = alloca(blen + 1);
breaks = ast_alloca(blen + 1);
breaks[0] = '\0';
if (stop) {
strcat(breaks, stop);
@@ -1719,8 +1719,8 @@ static enum AST_LOCK_RESULT ast_lock_path_lockfile(const char *path)
int lp = strlen(path);
time_t start;
s = alloca(lp + 10);
fs = alloca(lp + 20);
s = ast_alloca(lp + 10);
fs = ast_alloca(lp + 20);
snprintf(fs, strlen(path) + 19, "%s/.lock-%08lx", path, ast_random());
fd = open(fs, O_WRONLY | O_CREAT | O_EXCL, AST_FILE_MODE);
@@ -1752,7 +1752,7 @@ static int ast_unlock_path_lockfile(const char *path)
char *s;
int res;
s = alloca(strlen(path) + 10);
s = ast_alloca(strlen(path) + 10);
snprintf(s, strlen(path) + 9, "%s/%s", path, ".lock");
@@ -1793,7 +1793,7 @@ static enum AST_LOCK_RESULT ast_lock_path_flock(const char *path)
struct path_lock *pl;
struct stat st, ost;
fs = alloca(strlen(path) + 20);
fs = ast_alloca(strlen(path) + 20);
snprintf(fs, strlen(path) + 19, "%s/lock", path);
if (lstat(fs, &st) == 0) {
@@ -1874,7 +1874,7 @@ static int ast_unlock_path_flock(const char *path)
char *s;
struct path_lock *p;
s = alloca(strlen(path) + 20);
s = ast_alloca(strlen(path) + 20);
AST_LIST_LOCK(&path_lock_list);
AST_LIST_TRAVERSE_SAFE_BEGIN(&path_lock_list, p, le) {