mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 12:37:35 +00:00
Merge pull request #2696 from brauner/2018-10-17/fix_append_config_line
confile: fix append_unexp_config_line()
This commit is contained in:
commit
5fb2bc71b6
@ -2038,10 +2038,12 @@ static int set_config_console_size(const char *key, const char *value,
|
|||||||
|
|
||||||
int append_unexp_config_line(const char *line, struct lxc_conf *conf)
|
int append_unexp_config_line(const char *line, struct lxc_conf *conf)
|
||||||
{
|
{
|
||||||
size_t len = conf->unexpanded_len, linelen = strlen(line);
|
size_t linelen;
|
||||||
|
size_t len = conf->unexpanded_len;
|
||||||
|
|
||||||
update_hwaddr(line);
|
update_hwaddr(line);
|
||||||
|
|
||||||
|
linelen = strlen(line);
|
||||||
while (conf->unexpanded_alloced <= len + linelen + 2) {
|
while (conf->unexpanded_alloced <= len + linelen + 2) {
|
||||||
char *tmp = realloc(conf->unexpanded_config,
|
char *tmp = realloc(conf->unexpanded_config,
|
||||||
conf->unexpanded_alloced + 1024);
|
conf->unexpanded_alloced + 1024);
|
||||||
@ -2050,16 +2052,16 @@ int append_unexp_config_line(const char *line, struct lxc_conf *conf)
|
|||||||
|
|
||||||
if (!conf->unexpanded_config)
|
if (!conf->unexpanded_config)
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
|
|
||||||
conf->unexpanded_config = tmp;
|
conf->unexpanded_config = tmp;
|
||||||
conf->unexpanded_alloced += 1024;
|
conf->unexpanded_alloced += 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)strlcat(conf->unexpanded_config, line, conf->unexpanded_alloced);
|
memcpy(conf->unexpanded_config + conf->unexpanded_len, line, linelen);
|
||||||
conf->unexpanded_len += linelen;
|
conf->unexpanded_len += linelen;
|
||||||
if (line[linelen - 1] != '\n') {
|
if (line[linelen - 1] != '\n')
|
||||||
(void)strlcat(conf->unexpanded_config, "\n", conf->unexpanded_alloced);
|
conf->unexpanded_config[conf->unexpanded_len++] = '\n';
|
||||||
conf->unexpanded_len++;
|
conf->unexpanded_config[conf->unexpanded_len] = '\0';
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user