1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 01:55:10 +03:00

libdaemon: check for strdup result

Detect failure of dm_pool_strdup() and print error in fail path.
Save one extra strchr call - since we already know the distance
for the '=' character.

Drop stack trace from return after log_error().
This commit is contained in:
Zdenek Kabelac 2012-12-14 01:00:36 +01:00
parent ff5612c0c3
commit 788ac7fa54
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
Add check for key string duplication in config_make_nodes_v.
Add check for created fid in _scan_file.
Log output also to syslog when abort_on_internal_error is set.
Add LV snapshot support to liblvm and python-lvm.

View File

@ -215,7 +215,8 @@ struct dm_config_node *config_make_nodes_v(struct dm_config_tree *cft,
const char *next;
struct dm_config_node *first = NULL;
struct dm_config_node *cn;
const char *fmt, *key;
const char *fmt;
char *key;
while ((next = va_arg(ap, char *))) {
cn = NULL;
@ -223,12 +224,16 @@ struct dm_config_node *config_make_nodes_v(struct dm_config_tree *cft,
if (!fmt) {
log_error(INTERNAL_ERROR "Bad format string '%s'", fmt);
return_NULL;
return NULL;
}
fmt += 2;
key = dm_pool_strdup(cft->mem, next);
*strchr(key, '=') = 0;
if (!(key = dm_pool_strdup(cft->mem, next))) {
log_error("Failed to duplicate node key.");
return NULL;
}
key[fmt - next] = '\0';
fmt += 2;
if (!strcmp(fmt, "%d") || !strcmp(fmt, "%" PRId64)) {
int64_t value = va_arg(ap, int64_t);
@ -247,7 +252,7 @@ struct dm_config_node *config_make_nodes_v(struct dm_config_tree *cft,
chain_node(cn, parent, pre_sib);
} else {
log_error(INTERNAL_ERROR "Bad format string '%s'", fmt);
return_NULL;
return NULL;
}
if (!first)
first = cn;