[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [python PATCH] Check return value of libvirt_uintUnwrap



On Thu, Nov 06, 2014 at 12:04:54 +0100, Pavel Hrdina wrote:
> On 11/06/2014 11:05 AM, Jiri Denemark wrote:
> > libvirt_virDomainSendKey didn't check whether libvirt_uintUnwrap
> > succeeded or not.
> >
> > https://bugzilla.redhat.com/show_bug.cgi?id=1161039
> > Signed-off-by: Jiri Denemark <jdenemar redhat com>
> > ---
> >
> > Providing extra context for easier review...
> >
> >   libvirt-override.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libvirt-override.c b/libvirt-override.c
> > index a53b46f..f496c6e 100644
> > --- a/libvirt-override.c
> > +++ b/libvirt-override.c
> > @@ -7119,47 +7119,48 @@ static PyObject *
> >   libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED,
> >                            PyObject *args)
> >   {
> >       PyObject *py_retval;
> >       virDomainPtr domain;
> >       PyObject *pyobj_domain;
> >       PyObject *pyobj_list;
> >       int codeset;
> >       int holdtime;
> >       unsigned int flags;
> >       int ret;
> >       size_t i;
> >       unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
> >       unsigned int nkeycodes;
> >
> >       if (!PyArg_ParseTuple(args, (char *)"OiiOiI:virDomainSendKey",
> >                             &pyobj_domain, &codeset, &holdtime, &pyobj_list,
> >                             &nkeycodes, &flags)) {
> >           DEBUG("%s failed to parse tuple\n", __FUNCTION__);
> >           return VIR_PY_INT_FAIL;
> >       }
> >       domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
> >
> >       if (!PyList_Check(pyobj_list)) {
> >           return VIR_PY_INT_FAIL;
> >       }
> >
> >       if (nkeycodes != PyList_Size(pyobj_list) ||
> >           nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
> >           return VIR_PY_INT_FAIL;
> >       }
> >
> >       for (i = 0; i < nkeycodes; i++) {
> > -        libvirt_uintUnwrap(PyList_GetItem(pyobj_list, i), &(keycodes[i]));
> > +        if (libvirt_uintUnwrap(PyList_GetItem(pyobj_list, i), &keycodes[i]) < 0)
> > +            return VIR_PY_INT_FAIL;
> 
> Return NULL instead of PyObject with value -1. Function 
> "libvirt_uintUnwrap" sets an exception on error and in that case the 
> NULL should be returned.
> 
> ACK with that change,

Fixed and pushed, thanks.

Jirka


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]