summaryrefslogtreecommitdiff
path: root/main/config.c
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/config.c
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/config.c')
-rw-r--r--main/config.c24
1 files changed, 14 insertions, 10 deletions
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, '\"')))