]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
make the 'name' and 'value' fields in ast_variable const char *
authorLuigi Rizzo <rizzo@icir.org>
Wed, 14 Nov 2007 13:18:40 +0000 (13:18 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Wed, 14 Nov 2007 13:18:40 +0000 (13:18 +0000)
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: https://origsvn.digium.com/svn/asterisk/trunk@89268 65c4cc65-6c06-0410-ace0-fbb531ad65f3

23 files changed:
apps/app_directory.c
apps/app_minivm.c
apps/app_playback.c
apps/app_queue.c
apps/app_voicemail.c
channels/chan_agent.c
channels/chan_iax2.c
channels/chan_oss.c
channels/chan_sip.c
channels/chan_skinny.c
include/asterisk/abstract_jb.h
include/asterisk/acl.h
include/asterisk/config.h
main/abstract_jb.c
main/acl.c
main/config.c
main/enum.c
main/logger.c
main/manager.c
pbx/dundi-parser.c
pbx/dundi-parser.h
pbx/pbx_dundi.c
res/res_adsi.c

index 05460c409e1a57d60f464cd7e4ab5280205abe29..010899d378cba227b37181c592f793358ec3421f 100644 (file)
@@ -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;
index 6e7a29bd2573ed01a877190aab0357249fc65b64..1bca5a333c9ecd15c1447e953004f8a57c6bd9b4 100644 (file)
@@ -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];
index 5e88a1deb82f28e5c5823fc56d0db0d53da61034..ea091a9d1936f007ea803e3102b63a11ef00a90b 100644 (file)
@@ -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");
index f8798b0650132a99c2dae997ccaebbb1b6f5061c..42328541b0ffd485d65226dd5c8b6cf1823dfff4 100644 (file)
@@ -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;
index 9b7787b3b1160a65db5f5f5bfa6d6f0f49f7a5c1..91b7409bea4bc2855e009ecd04694132470efa9d 100644 (file)
@@ -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;
index 342f46754d98b730ce3bf002e7677d436f7cf279..99462e78dd2f6379e5cfe492fe6215d80c0b76bf 100644 (file)
@@ -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,
index 0e3a8f78d6f9cc76c6066628fa0cb76de2fa25cd..729b89db52005730cc5b55973d87b1e047fe3849 100644 (file)
@@ -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"))
index 1caf1a378128f2befab8bede5652cc7c63331f0e..7c2d60e279f69354cd8a7a7a9ded91449a4f33e7 100644 (file)
@@ -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));
 }
index 4953de219ff50298ae11d7a8238893a1d83fc4bd..291c31c3cc385f068d231188ec71044bf48c3380 100644 (file)
@@ -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;
index 6808d32a49929b02d02df766321eca8d6107d99c..fd1dcb41237864bdf2f5e07ffae76a40e1541dc9 100644 (file)
@@ -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';
index 145256fcf433bba1679b2e6a03693fda141f3f8f..9342dca8283b3923664db3df5b1287e8e8588dec 100644 (file)
@@ -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);
 
 
 /*!
index 7b107641ce82ee732a873f5e7b63ce4dcdd400ef..db626c2281e8e439554ece7f28d2a170a104d127 100644 (file)
@@ -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);
index 2064ba5e341750612b0dfd96189d4215d9916ae8..ea360991ba3cd4c78e91a1b33727fe15fc2b934f 100644 (file)
@@ -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];
 };
 
index e108aa92c7b1ad61c052886561d6aff2e6eb0d95..b8ccfbd9307f45c531c02e396079fb2b5b830602 100644 (file)
@@ -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))
index 137aafa7035f7fefd9d58268d3237346af0f1808..110bb51f83676fdc392ccce579cdb44ad85a1728 100644 (file)
@@ -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;
index 614c6c9e72805f55cc5ea9ca4db2f4765d0461cb..1884ec69c348893ec28c321d55870a01c67338b3 100644 (file)
@@ -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, '\"')))
index 9e771b948f8b6025abf65149bbfaee7ffbb1ac41..9397f0f78e60e864c6e1736dfead69b5ef882ce5 100644 (file)
@@ -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;
 
index c1c8751e4fbed3f2ae280061100de2c5f79b1aa5..a5c7dd93a4c7b0878569441e265cfab737526bc2 100644 (file)
@@ -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;
index c329a949001180b962b9b34f66945a23d1e72138..791e839d0dca03d5651bc61e5733b36345d64f88 100644 (file)
@@ -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);
index 42d79dc297e36487ecb076a2bf1041bd97ff8a5e..e618264a0dac7397a5339fd9f96a00baaa3fdd2e 100644 (file)
@@ -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;
index 62bbf4384276501c0f9c0860cd81848447d7fc9b..8ff77234764790a84e8d3f1941c1c60348867357 100644 (file)
@@ -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);
index 05748b39705f678fcfef0b595882cec159b0dbf8..611483a3743a32938663ad1e9f354202d943841c 100644 (file)
@@ -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;
index 08ae71f7c51bea5cf81881908c74d965a610646a..ae166fe127f8c3f82ab21fbf5c4e6bf2811d68fe 100644 (file)
@@ -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)