mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-03 21:21:39 +00:00
Fix handling of empty config keys
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
87b86add6c
commit
2eee1b96c6
@ -332,7 +332,7 @@ static int print_info(const char *name, const char *lxcpath)
|
||||
for(i = 0; i < keys; i++) {
|
||||
int len = c->get_config_item(c, key[i], NULL, 0);
|
||||
|
||||
if (len >= 0) {
|
||||
if (len > 0) {
|
||||
char *val = (char*) malloc(sizeof(char)*len + 1);
|
||||
|
||||
if (c->get_config_item(c, key[i], val, len + 1) != len) {
|
||||
@ -341,8 +341,10 @@ static int print_info(const char *name, const char *lxcpath)
|
||||
printf("%s = %s\n", key[i], val);
|
||||
}
|
||||
free(val);
|
||||
} else if (len == 0) {
|
||||
printf("%s =\n", key[i]);
|
||||
} else {
|
||||
fprintf(stderr, "%s unset or invalid\n", key[i]);
|
||||
fprintf(stderr, "%s invalid\n", key[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -843,6 +843,10 @@ Container_get_config_item(Container *self, PyObject *args, PyObject *kwds)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
return PyUnicode_FromString("");
|
||||
}
|
||||
|
||||
char* value = (char*) malloc(sizeof(char)*len + 1);
|
||||
if (value == NULL)
|
||||
return PyErr_NoMemory();
|
||||
|
Loading…
Reference in New Issue
Block a user