diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-25 14:32:08 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-25 14:32:08 +0000 |
commit | 000e0986072e528276eb7ea9a37728b5b0e6be76 (patch) | |
tree | b186c37b5085861c464a92debbf99dd8c2b71780 /apps/app_parkandannounce.c | |
parent | c3ad9c9ef53aa9d4297f7c0f009da3c33f50bebc (diff) |
apparently developers are still not aware that they should be use ast_copy_string instead of strncpy... fix up many more users, and fix some bugs in the process
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46200 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_parkandannounce.c')
-rw-r--r-- | apps/app_parkandannounce.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c index 66203b1b0..b4e9006fb 100644 --- a/apps/app_parkandannounce.c +++ b/apps/app_parkandannounce.c @@ -78,13 +78,13 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data) { int res=0; char *return_context; - int l, lot, timeout = 0, dres; + int lot, timeout = 0, dres; char *working, *context, *exten, *priority, *dial, *dialtech, *dialstr; char *template, *tpl_working, *tpl_current; char *tmp[100]; char buf[13]; int looptemp=0,i=0; - char *s,*orig_s; + char *s; struct ast_channel *dchan; struct outgoing_helper oh; @@ -99,18 +99,11 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data) u = ast_module_user_add(chan); - l=strlen(data)+2; - if (!(orig_s = ast_malloc(l))) { - ast_module_user_remove(u); - return -1; - } - s=orig_s; - strncpy(s,data,l); + s = ast_strdupa(data); template=strsep(&s,"|"); if(! template) { ast_log(LOG_WARNING, "PARK: An announce template must be defined\n"); - free(orig_s); ast_module_user_remove(u); return -1; } @@ -122,7 +115,6 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data) dial=strsep(&s, "|"); if(!dial) { ast_log(LOG_WARNING, "PARK: A dial resource must be specified i.e: Console/dsp or Zap/g1/5551212\n"); - free(orig_s); ast_module_user_remove(u); return -1; } else { @@ -155,16 +147,15 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data) } if(atoi(priority) < 0) { ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", priority); - free(orig_s); ast_module_user_remove(u); return -1; } /* At this point we have a priority and maybe an extension and a context */ chan->priority = atoi(priority); if (exten) - strncpy(chan->exten, exten, sizeof(chan->exten)-1); + ast_copy_string(chan->exten, exten, sizeof(chan->exten)); if (context) - strncpy(chan->context, context, sizeof(chan->context)-1); + ast_copy_string(chan->context, context, sizeof(chan->context)); } else { /* increment the priority by default*/ chan->priority++; } @@ -202,13 +193,11 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data) ast_verbose(VERBOSE_PREFIX_4 "Channel %s was never answered.\n", dchan->name); ast_log(LOG_WARNING, "PARK: Channel %s was never answered for the announce.\n", dchan->name); ast_hangup(dchan); - free(orig_s); ast_module_user_remove(u); return -1; } } else { ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n"); - free(orig_s); ast_module_user_remove(u); return -1; } @@ -245,7 +234,6 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data) ast_stopstream(dchan); ast_hangup(dchan); - free(orig_s); ast_module_user_remove(u); |