summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2007-11-14 13:18:40 +0000
committerLuigi Rizzo <rizzo@icir.org>2007-11-14 13:18:40 +0000
commit7f8ecd2cd39ac2299ec08deb4dc92839be5412d1 (patch)
tree01f0ca16e50b44357fb29bdb18793405a071da0f /main
parentd3414c7552012dac078288cc73e813a17a99e94d (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: https://origsvn.digium.com/svn/asterisk/trunk@89268 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-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
6 files changed, 23 insertions, 19 deletions
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);