aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-24 01:28:45 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-24 01:28:45 +0000
commit217ac79e02e4ada9dadbc87278721afa59427fce (patch)
treef132b0899f21326a2d02efa0dcf9522ce162cf83 /utils
parente8e7c4ec315d766e49cfc2591aa63ab637303cce (diff)
Merged revisions 46067 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r46067 | russell | 2006-10-23 21:27:42 -0400 (Mon, 23 Oct 2006) | 7 lines In muted.c, check the return value of strdup. In ael_main.c, check the return value of calloc. (issue #8157) In passing fix a few minor bugs in ael_main.c. The last argument to strncpy() was a hard-coded 100, where it should have been 99. I changed this to use sizeof() - 1. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@46068 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils')
-rw-r--r--utils/ael_main.c16
-rw-r--r--utils/muted.c16
2 files changed, 23 insertions, 9 deletions
diff --git a/utils/ael_main.c b/utils/ael_main.c
index 225e23b91..606ac8d6a 100644
--- a/utils/ael_main.c
+++ b/utils/ael_main.c
@@ -62,8 +62,10 @@ void destroy_namelist(struct namelist *x)
struct namelist *create_name(char *name);
struct namelist *create_name(char *name)
{
- struct namelist *x = (struct namelist *)calloc(sizeof(struct namelist),1);
- strncpy(x->name,name,100);
+ struct namelist *x = calloc(1, sizeof(*x));
+ if (!x)
+ return NULL;
+ strncpy(x->name, name, sizeof(x->name) - 1);
return x;
}
@@ -253,14 +255,16 @@ void pbx_builtin_setvar(void *chan, void *data)
struct ast_context * ast_context_create(void **extcontexts, const char *name, const char *registrar)
{
- struct ast_context *x = (struct ast_context *)calloc(sizeof(struct ast_context),1);
+ struct ast_context *x = calloc(1, sizeof(*x));
+ if (!x)
+ return NULL;
x->next = context_list;
context_list = x;
- if(!no_comp)
+ if (!no_comp)
printf("Executed ast_context_create(conts, name=%s, registrar=%s);\n", name, registrar);
conts++;
- strncpy(x->name,name,100);
- strncpy(x->registrar,registrar,100);
+ strncpy(x->name, name, sizeof(x->name) - 1);
+ strncpy(x->registrar, registrar, sizeof(x->registrar) - 1);
return x;
}
diff --git a/utils/muted.c b/utils/muted.c
index 879bea583..6a32b6d99 100644
--- a/utils/muted.c
+++ b/utils/muted.c
@@ -85,8 +85,15 @@ static void add_channel(char *tech, char *location)
chan = malloc(sizeof(struct channel));
if (chan) {
memset(chan, 0, sizeof(struct channel));
- chan->tech = strdup(tech);
- chan->location = strdup(location);
+ if (!(chan->tech = strdup(tech))) {
+ free(chan);
+ return;
+ }
+ if (!(chan->location = strdup(location))) {
+ free(chan->tech);
+ free(chan);
+ return;
+ }
chan->next = channels;
channels = chan;
}
@@ -550,7 +557,10 @@ static void append_sub(struct channel *chan, char *name)
sub = malloc(sizeof(struct subchannel));
if (sub) {
memset(sub, 0, sizeof(struct subchannel));
- sub->name = strdup(name);
+ if (!(sub->name = strdup(name))) {
+ free(sub);
+ return;
+ }
sub->next = chan->subs;
chan->subs = sub;
}