summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2012-07-31 20:21:43 +0000
committerKinsey Moore <kmoore@digium.com>2012-07-31 20:21:43 +0000
commit9b16c8b0f6c3b6310e303411421bfcb16b26c3c4 (patch)
tree273c31a834a21bd2239ec6b83cd35c602ea25d26 /res
parent6c23a60f802e7708389b1a6463a40dc0500512bd (diff)
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
Diffstat (limited to 'res')
-rw-r--r--res/ael/pval.c2
-rw-r--r--res/res_agi.c5
-rw-r--r--res/res_config_pgsql.c6
-rw-r--r--res/res_http_websocket.c2
-rw-r--r--res/res_jabber.c4
5 files changed, 10 insertions, 9 deletions
diff --git a/res/ael/pval.c b/res/ael/pval.c
index ff425f543..70bd68986 100644
--- a/res/ael/pval.c
+++ b/res/ael/pval.c
@@ -2902,7 +2902,7 @@ void ael2_semantic_check(pval *item, int *arg_errs, int *arg_warns, int *arg_not
if (!item)
return; /* don't check an empty tree */
#ifdef AAL_ARGCHECK
- rfilename = alloca(10 + strlen(ast_config_AST_VAR_DIR));
+ rfilename = ast_alloca(10 + strlen(ast_config_AST_VAR_DIR));
sprintf(rfilename, "%s/applist", ast_config_AST_VAR_DIR);
apps = argdesc_parse(rfilename, &argapp_errs); /* giveth */
diff --git a/res/res_agi.c b/res/res_agi.c
index 328674c5a..6f7675f53 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -1571,10 +1571,11 @@ static enum agi_result launch_ha_netscript(char *agiurl, char *argv[], int *fds)
unsigned short srvport;
/* format of agiurl is "hagi://host.domain[:port][/script/name]" */
- if (!(host = ast_strdupa(agiurl + 7))) { /* Remove hagi:// */
+ if (strlen(agiurl) < 7) { /* Remove hagi:// */
ast_log(LOG_WARNING, "An error occurred parsing the AGI URI: %s", agiurl);
return AGI_RESULT_FAILURE;
}
+ host = ast_strdupa(agiurl + 7);
/* Strip off any script name */
if ((script = strchr(host, '/'))) {
@@ -2500,7 +2501,7 @@ static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, const char
ast_set_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS);
}
if (ast_compat_res_agi && argc >= 3 && !ast_strlen_zero(argv[2])) {
- char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr;
+ char *compat = ast_alloca(strlen(argv[2]) * 2 + 1), *cptr;
const char *vptr;
for (cptr = compat, vptr = argv[2]; *vptr; vptr++) {
if (*vptr == ',') {
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 02c76fcfe..bafa27197 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -290,7 +290,7 @@ static struct tables *find_table(const char *database, const char *orig_tablenam
if (strchr(schemaname, '\\') || strchr(schemaname, '\'')) {
char *tmp = schemaname, *ptr;
- ptr = schemaname = alloca(strlen(tmp) * 2 + 1);
+ ptr = schemaname = ast_alloca(strlen(tmp) * 2 + 1);
for (; *tmp; tmp++) {
if (strchr("\\'", *tmp)) {
*ptr++ = *tmp;
@@ -303,7 +303,7 @@ static struct tables *find_table(const char *database, const char *orig_tablenam
if (strchr(tablename, '\\') || strchr(tablename, '\'')) {
char *tmp = tablename, *ptr;
- ptr = tablename = alloca(strlen(tmp) * 2 + 1);
+ ptr = tablename = ast_alloca(strlen(tmp) * 2 + 1);
for (; *tmp; tmp++) {
if (strchr("\\'", *tmp)) {
*ptr++ = *tmp;
@@ -322,7 +322,7 @@ static struct tables *find_table(const char *database, const char *orig_tablenam
const char *tmp = orig_tablename;
char *ptr;
- orig_tablename = ptr = alloca(strlen(tmp) * 2 + 1);
+ orig_tablename = ptr = ast_alloca(strlen(tmp) * 2 + 1);
for (; *tmp; tmp++) {
if (strchr("\\'", *tmp)) {
*ptr++ = *tmp;
diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index c5fcdeeee..86e2a82a3 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -208,7 +208,7 @@ int ast_websocket_write(struct ast_websocket *session, enum ast_websocket_opcode
header_size += 8;
}
- frame = alloca(header_size);
+ frame = ast_alloca(header_size);
memset(frame, 0, sizeof(*frame));
frame[0] = opcode | 0x80;
diff --git a/res/res_jabber.c b/res/res_jabber.c
index c160266b0..9cab2f159 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -1585,8 +1585,8 @@ static int aji_start_sasl(struct aji_client *client, enum ikssasltype type, char
iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_SASL);
len = strlen(username) + strlen(pass) + 3;
- s = alloca(len);
- base64 = alloca((len + 2) * 4 / 3);
+ s = ast_alloca(len);
+ base64 = ast_alloca((len + 2) * 4 / 3);
iks_insert_attrib(x, "mechanism", "PLAIN");
snprintf(s, len, "%c%s%c%s", 0, username, 0, pass);