segfault in nl_object_clone

Teto mattator at gmail.com
Mon Oct 14 11:50:03 EDT 2013


Hi,

I just had a segfault while calling  the class Object(object)
constructor from python binding at the level of
capi.nl_object_clone(self._nl_object):
    def __init__(self, obj_name, name, obj=None):
        self._obj_name = obj_name
        self._name = name
        self._modules = []

        if not obj:
            obj = capi.object_alloc_name(self._obj_name)
            if not obj:
                raise ValueError( "[" + self._obj_name + "] does not
look like a valid name" )


        clone_obj = capi.nl_object_clone(self._nl_object)
        self._orig = self._obj2type(clone_obj)

Looks like calling nl_object_clone on an empty nl_object crashes
because there is no check in nl_object_clone to detect e NULL
parameter, which case happens when you provide a bad name in
capi.object_alloc_name(self._obj_name). I suggest to add a check after
object allocation in this way:
        if not obj:
            obj = capi.object_alloc_name(self._obj_name)
            if not obj:
                raise ValueError( "[" + self._obj_name + "] does not
look like a valid name" )

This happened to me while trying to initialize flnl_request but it
seems its operations are not registered into the cache manager. Any
idea why ?

Matt



More information about the libnl mailing list