aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-14 13:18:40 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-14 13:18:40 +0000
commitea0d4674a604b98a32c5f5b42f1878d3d75af9e0 (patch)
tree01f0ca16e50b44357fb29bdb18793405a071da0f
parent2e70fd87205ec4f9c775075b807c65e3703145e3 (diff)
make the 'name' and 'value' fields in ast_variable const char *
This prevents modifying the strings in the stored variables, and catched a few instances where this was actually done. Given the differences between trunk and 1.4 (and the fact that this is effectively an API change) it is better to fix 1.4 independently. These are chan_sip.c::sip_register() chan_skinny.c:: near line 2847 config.c:: near line 1774 logger.c::make_components() res_adsi.c:: near line 1049 I may have missed some instances for modules that do not build here. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@89268 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_directory.c4
-rw-r--r--apps/app_minivm.c6
-rw-r--r--apps/app_playback.c2
-rw-r--r--apps/app_queue.c7
-rw-r--r--apps/app_voicemail.c6
-rw-r--r--channels/chan_agent.c2
-rw-r--r--channels/chan_iax2.c6
-rw-r--r--channels/chan_oss.c8
-rw-r--r--channels/chan_sip.c15
-rw-r--r--channels/chan_skinny.c6
-rw-r--r--include/asterisk/abstract_jb.h2
-rw-r--r--include/asterisk/acl.h2
-rw-r--r--include/asterisk/config.h8
-rw-r--r--main/abstract_jb.c4
-rw-r--r--main/acl.c2
-rw-r--r--main/config.c24
-rw-r--r--main/enum.c2
-rw-r--r--main/logger.c6
-rw-r--r--main/manager.c4
-rw-r--r--pbx/dundi-parser.c4
-rw-r--r--pbx/dundi-parser.h4
-rw-r--r--pbx/pbx_dundi.c4
-rw-r--r--res/res_adsi.c9
23 files changed, 76 insertions, 61 deletions
diff --git a/apps/app_directory.c b/apps/app_directory.c
index 05460c409..010899d37 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -277,8 +277,8 @@ static char *convert(const char *lastname)
* '1' for selected entry from directory
* '*' for skipped entry from directory
*/
-static int play_mailbox_owner(struct ast_channel *chan, char *context,
- char *dialcontext, char *ext, char *name, int readext,
+static int play_mailbox_owner(struct ast_channel *chan, const char *context,
+ const char *dialcontext, const char *ext, const char *name, int readext,
int fromappvm)
{
int res = 0;
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index 6e7a29bd2..1bca5a333 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -458,7 +458,7 @@ static double global_volgain; /*!< Volume gain for voicmemail via e-mail */
#define DEFAULT_CHARSET "ISO-8859-1"
/* Forward declarations */
-static char *message_template_parse_filebody(char *filename);
+static char *message_template_parse_filebody(const char *filename);
static char *message_template_parse_emailbody(const char *body);
static int create_vmaccount(char *name, struct ast_variable *var, int realtime);
static struct minivm_account *find_user_realtime(const char *domain, const char *username);
@@ -2182,7 +2182,7 @@ static void timezone_destroy_list(void)
}
/*! \brief Add time zone to memory list */
-static int timezone_add(char *zonename, char *config)
+static int timezone_add(const char *zonename, const char *config)
{
struct minivm_zone *newzone;
@@ -2220,7 +2220,7 @@ static int timezone_add(char *zonename, char *config)
}
/*! \brief Read message template from file */
-static char *message_template_parse_filebody(char *filename) {
+static char *message_template_parse_filebody(const char *filename) {
char buf[BUFSIZ * 6];
char readbuf[BUFSIZ];
char filenamebuf[BUFSIZ];
diff --git a/apps/app_playback.c b/apps/app_playback.c
index 5e88a1deb..ea091a9d1 100644
--- a/apps/app_playback.c
+++ b/apps/app_playback.c
@@ -325,7 +325,7 @@ static int say_datetime(struct ast_channel *chan, time_t t, const char *ints, co
/*
* remap the 'say' functions to use those in this file
*/
-static int say_init_mode(char *mode) {
+static int say_init_mode(const char *mode) {
if (!strcmp(mode, say_new)) {
if (say_cfg == NULL) {
ast_log(LOG_ERROR, "There is no say.conf file to use new mode\n");
diff --git a/apps/app_queue.c b/apps/app_queue.c
index f8798b065..42328541b 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1242,7 +1242,8 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
struct member *m;
struct ao2_iterator mem_iter;
char *interface = NULL;
- char *tmp, *tmp_name;
+ const char *tmp_name;
+ char *tmp;
char tmpbuf[64]; /* Must be longer than the longest queue param name. */
/* Static queues override realtime. */
@@ -1300,7 +1301,7 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
if ((tmp = strchr(v->name, '_'))) {
ast_copy_string(tmpbuf, v->name, sizeof(tmpbuf));
tmp_name = tmpbuf;
- tmp = tmp_name;
+ tmp = tmpbuf;
while ((tmp = strchr(tmp, '_')))
*tmp++ = '-';
} else
@@ -2664,7 +2665,7 @@ static void send_agent_complete(const struct queue_ent *qe, const char *queuenam
const struct ast_channel *peer, const struct member *member, time_t callstart,
char *vars, size_t vars_len, enum agent_complete_reason rsn)
{
- const char *reason;
+ const char *reason = NULL; /* silence dumb compilers */
if (!qe->parent->eventwhencalled)
return;
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 9b7787b3b..91b7409be 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1652,7 +1652,7 @@ static void copy_file(char *frompath, char *topath)
{
char frompath2[PATH_MAX], topath2[PATH_MAX];
struct ast_variable *tmp,*var = NULL;
- char *origmailbox = NULL, *context = NULL, *macrocontext = NULL, *exten = NULL, *priority = NULL, *callerchan = NULL, *callerid = NULL, *origdate = NULL, *origtime = NULL, *category = NULL, *duration = NULL;
+ const char *origmailbox = NULL, *context = NULL, *macrocontext = NULL, *exten = NULL, *priority = NULL, *callerchan = NULL, *callerid = NULL, *origdate = NULL, *origtime = NULL, *category = NULL, *duration = NULL;
ast_filecopy(frompath, topath, NULL);
snprintf(frompath2, sizeof(frompath2), "%s.txt", frompath);
snprintf(topath2, sizeof(topath2), "%s.txt", topath);
@@ -7400,7 +7400,7 @@ static int vm_exec(struct ast_channel *chan, void *data)
return res;
}
-static struct ast_vm_user *find_or_create(char *context, char *mbox)
+static struct ast_vm_user *find_or_create(const char *context, const char *mbox)
{
struct ast_vm_user *vmu;
@@ -7425,7 +7425,7 @@ static struct ast_vm_user *find_or_create(char *context, char *mbox)
return vmu;
}
-static int append_mailbox(char *context, char *mbox, char *data)
+static int append_mailbox(const char *context, const char *mbox, const char *data)
{
/* Assumes lock is already held */
char *tmp;
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 342f46754..99462e78d 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -267,7 +267,7 @@ static const struct ast_channel_tech agent_tech = {
* @return The just created agent.
* \sa agent_pvt, agents.
*/
-static struct agent_pvt *add_agent(char *agent, int pending)
+static struct agent_pvt *add_agent(const char *agent, int pending)
{
char *parse;
AST_DECLARE_APP_ARGS(args,
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 0e3a8f78d..729b89db5 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -6287,7 +6287,7 @@ static int iax2_append_register(const char *hostname, const char *username,
return 0;
}
-static int iax2_register(char *value, int lineno)
+static int iax2_register(const char *value, int lineno)
{
char copy[256];
char *username, *hostname, *secret;
@@ -9592,7 +9592,7 @@ static int start_network_thread(void)
return 0;
}
-static struct iax2_context *build_context(char *context)
+static struct iax2_context *build_context(const char *context)
{
struct iax2_context *con;
@@ -9602,7 +9602,7 @@ static struct iax2_context *build_context(char *context)
return con;
}
-static int get_auth_methods(char *value)
+static int get_auth_methods(const char *value)
{
int methods = 0;
if (strstr(value, "rsa"))
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 1caf1a378..7c2d60e27 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -212,7 +212,7 @@ END_CONFIG
* Likely we will come up with a better way of doing config file parsing.
*/
#define M_START(var, val) \
- char *__s = var; char *__val = val;
+ const char *__s = var; const char *__val = val;
#define M_END(x) x;
#define M_F(tag, f) if (!strcasecmp((__s), tag)) { f; } else
#define M_BOOL(tag, dst) M_F(tag, (dst) = ast_true(__val) )
@@ -1413,7 +1413,7 @@ static char *console_active(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
/*!
* \brief store the boost factor
*/
-static void store_boost(struct chan_oss_pvt *o, char *s)
+static void store_boost(struct chan_oss_pvt *o, const char *s)
{
double boost = 0;
if (sscanf(s, "%lf", &boost) != 1) {
@@ -1472,7 +1472,7 @@ static struct ast_cli_entry cli_oss[] = {
* invalid or dangerous values (the string is used as argument for
* system("mixer %s")
*/
-static void store_mixer(struct chan_oss_pvt *o, char *s)
+static void store_mixer(struct chan_oss_pvt *o, const char *s)
{
int i;
@@ -1491,7 +1491,7 @@ static void store_mixer(struct chan_oss_pvt *o, char *s)
/*!
* store the callerid components
*/
-static void store_callerid(struct chan_oss_pvt *o, char *s)
+static void store_callerid(struct chan_oss_pvt *o, const char *s)
{
ast_callerid_split(s, o->cid_name, sizeof(o->cid_name), o->cid_num, sizeof(o->cid_num));
}
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 4953de219..291c31c3c 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1572,7 +1572,7 @@ static int add_sip_domain(const char *domain, const enum domain_mode mode, const
static void clear_sip_domains(void);
/*--- SIP realm authentication */
-static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno);
+static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, const char *configuration, int lineno);
static int clear_realm_authentication(struct sip_auth *authlist); /* Clear realm authentication list (at reload) */
static struct sip_auth *find_realm_authentication(struct sip_auth *authlist, const char *realm);
@@ -1686,7 +1686,7 @@ static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli
/*--- Internal UA client handling (outbound registrations) */
static void ast_sip_ouraddrfor(struct in_addr *them, struct sockaddr_in *us);
static void sip_registry_destroy(struct sip_registry *reg);
-static int sip_register(char *value, int lineno);
+static int sip_register(const char *value, int lineno);
static const char *regstate2str(enum sipregistrystate regstate) attribute_const;
static int sip_reregister(const void *data);
static int __sip_do_register(struct sip_registry *r);
@@ -5248,7 +5248,7 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
}
/*! \brief Parse register=> line in sip.conf and add to registry */
-static int sip_register(char *value, int lineno)
+static int sip_register(const char *value, int lineno)
{
struct sip_registry *reg;
int portnum = 0;
@@ -12545,8 +12545,11 @@ static char *sip_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a
initreqprep(&req, p, SIP_NOTIFY);
- for (var = varlist; var; var = var->next)
- add_header(&req, var->name, ast_unescape_semicolon(var->value));
+ for (var = varlist; var; var = var->next) {
+ char buf[512];
+ ast_copy_string(buf, var->value, sizeof(buf));
+ add_header(&req, var->name, ast_unescape_semicolon(buf));
+ }
/* Recalculate our side, and recalculate Call ID */
ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
@@ -17236,7 +17239,7 @@ static void clear_sip_domains(void)
/*! \brief Add realm authentication in list */
-static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno)
+static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, const char *configuration, int lineno)
{
char authcopy[256];
char *username=NULL, *realm=NULL, *secret=NULL, *md5secret=NULL;
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 6808d32a4..fd1dcb412 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -2847,8 +2847,10 @@ static struct skinny_device *build_device(const char *cat, struct ast_variable *
if (!(sd = ast_calloc(1, sizeof(*sd)))) {
return NULL;
} else {
- char *stringp, *exten, *context, *label;
- stringp = v->value;
+ char buf[256];
+ char *stringp = buf, *exten, *context, *label;
+
+ ast_copy_string(buf, v->value, sizeof(buf));
exten = strsep(&stringp, ",");
if ((context = strchr(exten, '@'))) {
*context++ = '\0';
diff --git a/include/asterisk/abstract_jb.h b/include/asterisk/abstract_jb.h
index 145256fcf..9342dca82 100644
--- a/include/asterisk/abstract_jb.h
+++ b/include/asterisk/abstract_jb.h
@@ -193,7 +193,7 @@ void ast_jb_destroy(struct ast_channel *chan);
*
* \return zero if the property was set to the configuration, -1 if not.
*/
-int ast_jb_read_conf(struct ast_jb_conf *conf, char *varname, char *value);
+int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value);
/*!
diff --git a/include/asterisk/acl.h b/include/asterisk/acl.h
index 7b107641c..db626c228 100644
--- a/include/asterisk/acl.h
+++ b/include/asterisk/acl.h
@@ -56,7 +56,7 @@ struct ast_ha {
void ast_free_ha(struct ast_ha *ha);
/*! \brief Append ACL entry to host access list. */
-struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int *error);
+struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error);
/*! \brief Check IP address with host access list */
int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin);
diff --git a/include/asterisk/config.h b/include/asterisk/config.h
index 2064ba5e3..ea360991b 100644
--- a/include/asterisk/config.h
+++ b/include/asterisk/config.h
@@ -50,16 +50,18 @@ enum {
/*! \brief Structure for variables, used for configurations and for channel variables
*/
struct ast_variable {
- char *name;
- char *value;
+ const char *name;
+ const char *value;
+ struct ast_variable *next;
+
char *file;
+
int lineno;
int object; /*!< 0 for variable, 1 for object */
int blanklines; /*!< Number of blanklines following entry */
struct ast_comment *precomments;
struct ast_comment *sameline;
struct ast_comment *trailing; /*!< the last object in the list will get assigned any trailing comments when EOF is hit */
- struct ast_variable *next;
char stuff[0];
};
diff --git a/main/abstract_jb.c b/main/abstract_jb.c
index e108aa92c..b8ccfbd93 100644
--- a/main/abstract_jb.c
+++ b/main/abstract_jb.c
@@ -562,10 +562,10 @@ static long get_now(struct ast_jb *jb, struct timeval *tv)
}
-int ast_jb_read_conf(struct ast_jb_conf *conf, char *varname, char *value)
+int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
{
int prefixlen = sizeof(AST_JB_CONF_PREFIX) - 1;
- char *name;
+ const char *name;
int tmp;
if (strncasecmp(AST_JB_CONF_PREFIX, varname, prefixlen))
diff --git a/main/acl.c b/main/acl.c
index 137aafa70..110bb51f8 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -120,7 +120,7 @@ struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original)
return ret; /* Return start of list */
}
-struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int *error)
+struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
{
struct ast_ha *ha;
char *nm;
diff --git a/main/config.c b/main/config.c
index 614c6c9e7..1884ec69c 100644
--- a/main/config.c
+++ b/main/config.c
@@ -259,14 +259,16 @@ struct ast_variable *ast_variable_new(const char *name, const char *value, const
{
struct ast_variable *variable;
int name_len = strlen(name) + 1;
-
- if ((variable = ast_calloc(1, name_len + strlen(value) + 1 + strlen(filename) + 1 + sizeof(*variable)))) {
- variable->name = variable->stuff;
- variable->value = variable->stuff + name_len;
- variable->file = variable->stuff + name_len + strlen(value) + 1;
- strcpy(variable->name,name);
- strcpy(variable->value,value);
- strcpy(variable->file,filename);
+ int val_len = strlen(value) + 1;
+ int fn_len = strlen(filename) + 1;
+
+ if ((variable = ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable)))) {
+ char *dst = variable->stuff; /* writable space starts here */
+ variable->name = strcpy(dst, name);
+ dst += name_len;
+ variable->value = strcpy(dst, value);
+ dst += fn_len;
+ variable->file = strcpy(dst, value);
}
return variable;
}
@@ -1721,7 +1723,7 @@ static void clear_config_maps(void)
ast_mutex_unlock(&config_lock);
}
-static int append_mapping(char *name, char *driver, char *database, char *table)
+static int append_mapping(const char *name, const char *driver, const char *database, const char *table)
{
struct ast_config_map *map;
int length;
@@ -1772,7 +1774,9 @@ int read_config_maps(void)
}
for (v = ast_variable_browse(config, "settings"); v; v = v->next) {
- stringp = v->value;
+ char buf[512];
+ ast_copy_string(buf, v->value, sizeof(buf));
+ stringp = buf;
driver = strsep(&stringp, ",");
if ((tmp = strchr(stringp, '\"')))
diff --git a/main/enum.c b/main/enum.c
index 9e771b948..9397f0f78 100644
--- a/main/enum.c
+++ b/main/enum.c
@@ -594,7 +594,7 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *dst, int dst
}
/*! \brief Add enum tree to linked list */
-static struct enum_search *enum_newtoplev(char *s)
+static struct enum_search *enum_newtoplev(const char *s)
{
struct enum_search *tmp;
diff --git a/main/logger.c b/main/logger.c
index c1c8751e4..a5c7dd93a 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -174,11 +174,11 @@ AST_THREADSTORAGE(verbose_buf);
AST_THREADSTORAGE(log_buf);
#define LOG_BUF_INIT_SIZE 256
-static int make_components(char *s, int lineno)
+static int make_components(const char *s, int lineno)
{
char *w;
int res = 0;
- char *stringp = s;
+ char *stringp = ast_strdupa(s);
while ((w = strsep(&stringp, ","))) {
w = ast_skip_blanks(w);
@@ -204,7 +204,7 @@ static int make_components(char *s, int lineno)
return res;
}
-static struct logchannel *make_logchannel(char *channel, char *components, int lineno)
+static struct logchannel *make_logchannel(const char *channel, const char *components, int lineno)
{
struct logchannel *chan;
char *facility;
diff --git a/main/manager.c b/main/manager.c
index c329a9490..791e839d0 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -2973,9 +2973,9 @@ static void xml_copy_escape(struct ast_str **out, const char *src, int mode)
static void xml_translate(struct ast_str **out, char *in, struct ast_variable *vars, enum output_format format)
{
struct ast_variable *v;
- char *dest = NULL;
+ const char *dest = NULL;
char *var, *val;
- char *objtype = NULL;
+ const char *objtype = NULL;
int in_data = 0; /* parsing data */
int inobj = 0;
int xml = (format == FORMAT_XML);
diff --git a/pbx/dundi-parser.c b/pbx/dundi-parser.c
index 42d79dc29..e618264a0 100644
--- a/pbx/dundi-parser.c
+++ b/pbx/dundi-parser.c
@@ -88,7 +88,7 @@ char *dundi_eid_to_str_short(char *s, int maxlen, dundi_eid *eid)
return os;
}
-int dundi_str_to_eid(dundi_eid *eid, char *s)
+int dundi_str_to_eid(dundi_eid *eid, const char *s)
{
unsigned int eid_int[6];
int x;
@@ -100,7 +100,7 @@ int dundi_str_to_eid(dundi_eid *eid, char *s)
return 0;
}
-int dundi_str_short_to_eid(dundi_eid *eid, char *s)
+int dundi_str_short_to_eid(dundi_eid *eid, const char *s)
{
unsigned int eid_int[6];
int x;
diff --git a/pbx/dundi-parser.h b/pbx/dundi-parser.h
index 62bbf4384..8ff772347 100644
--- a/pbx/dundi-parser.h
+++ b/pbx/dundi-parser.h
@@ -79,8 +79,8 @@ extern int dundi_ie_append(struct dundi_ie_data *ied, unsigned char ie);
extern int dundi_parse_ies(struct dundi_ies *ies, unsigned char *data, int datalen);
extern char *dundi_eid_to_str(char *s, int maxlen, dundi_eid *eid);
extern char *dundi_eid_to_str_short(char *s, int maxlen, dundi_eid *eid);
-extern int dundi_str_to_eid(dundi_eid *eid, char *s);
-extern int dundi_str_short_to_eid(dundi_eid *eid, char *s);
+extern int dundi_str_to_eid(dundi_eid *eid, const char *s);
+extern int dundi_str_short_to_eid(dundi_eid *eid, const char *s);
extern int dundi_eid_zero(dundi_eid *eid);
extern int dundi_eid_cmp(dundi_eid *eid1, dundi_eid *eid2);
extern char *dundi_flags2str(char *s, int maxlen, int flags);
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 05748b397..611483a37 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -4219,7 +4219,7 @@ static void prune_mappings(void)
AST_LIST_UNLOCK(&peers);
}
-static void append_permission(struct permissionlist *permlist, char *s, int allow)
+static void append_permission(struct permissionlist *permlist, const char *s, int allow)
{
struct permission *perm;
@@ -4234,7 +4234,7 @@ static void append_permission(struct permissionlist *permlist, char *s, int allo
#define MAX_OPTS 128
-static void build_mapping(char *name, char *value)
+static void build_mapping(const char *name, const char *value)
{
char *t, *fields[MAX_OPTS];
struct dundi_mapping *map;
diff --git a/res/res_adsi.c b/res/res_adsi.c
index 08ae71f7c..ae166fe12 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -70,7 +70,8 @@ static int maxretries = DEFAULT_ADSI_MAX_RETRIES;
static char intro[ADSI_MAX_INTRO][20];
static int aligns[ADSI_MAX_INTRO];
-static char speeddial[ADSI_MAX_SPEED_DIAL][3][20];
+#define SPEEDDIAL_MAX_LEN 20
+static char speeddial[ADSI_MAX_SPEED_DIAL][3][SPEEDDIAL_MAX_LEN];
static int alignment = 0;
@@ -988,7 +989,7 @@ static int _ast_adsi_unload_session(struct ast_channel *chan)
return 0;
}
-static int str2align(char *s)
+static int str2align(const char *s)
{
if (!strncasecmp(s, "l", 1))
return ADSI_JUST_LEFT;
@@ -1048,7 +1049,9 @@ static void adsi_load(void)
x = 0;
for (v = ast_variable_browse(conf, "speeddial"); v; v = v->next) {
- char *stringp = v->value;
+ char buf[3 * SPEEDDIAL_MAX_LEN];
+ char *stringp = buf;
+ ast_copy_string(buf, v->value, sizeof(buf));
name = strsep(&stringp, ",");
sname = strsep(&stringp, ",");
if (!sname)