Skip to content
This repository was archived by the owner on Mar 19, 2020. It is now read-only.

Commit b95f410

Browse files
Chuck Shortstgraber
Chuck Short
authored andcommitted
Handle invalid global config keys
Signed-off-by: Chuck Short <[email protected]> Acked-by: Stéphane Graber <[email protected]>
1 parent 227e22e commit b95f410

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lxc.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,20 @@ LXC_get_global_config_item(PyObject *self, PyObject *args, PyObject *kwds)
325325
{
326326
static char *kwlist[] = {"key", NULL};
327327
char* key = NULL;
328+
const char* value = NULL;
328329

329330
if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
330331
&key))
331332
return NULL;
332333

333-
return PyUnicode_FromString(lxc_get_global_config_item(key));
334+
value = lxc_get_global_config_item(key);
335+
336+
if (!value) {
337+
PyErr_SetString(PyExc_KeyError, "Invalid configuration key");
338+
return NULL;
339+
}
340+
341+
return PyUnicode_FromString(value);
334342
}
335343

336344
static PyObject *

0 commit comments

Comments
 (0)