Re: [Prelude Hybrid IDS] #269: Wrong idmef_*_get_next_* python binding functions?
"Prelude Hybrid IDS" <[email protected]>
| Newsgroups | gmane.comp.security.ids.prelude.devel |
|---|---|
| Message-ID | <[email protected]> |
#269: Wrong idmef_*_get_next_* python binding functions? ------------------------------------+--------------------------------------- Reporter: [email protected] | Owner: yoann Type: defect | Status: new Priority: normal | Milestone: Libprelude 0.9.17 Component: libprelude | Version: 0.9 Severity: normal | Resolution: Keywords: python binding | ------------------------------------+--------------------------------------- Comment (by [email protected]): > Forgot to add: please tell me if the above modification works, so I can make a patch. No, it does not work (but the problem is different) : one enters in an infinite loop while retrieving next sources. I guess this is because the second argument is not updated in subsequent get_next_source calls. In each typemap directive, you have to: - test that if the second argument is '''not''' None, then it should be of the right type and - if it is the case, convert the python object to the corresponding C structure That is to say, something that generates to the following code in _prelude.c (in the case of idmef_source) (this is an experpt of the code without your patch): {{{ if ( SWIG_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_idmef_source, SWIG_POINTER_EXCEPTION|0) ) return NULL; }}} Sorry, I do not know the corresponding SWIG syntax... > It seems indeed that all *_get_* functions accepting a NULL argument are affected. Yes. I did not check them all, but at least the following types are affected : idmef_user_id_t idmef_address_t idmef_analyzer_t idmef_source_t idmef_target_t idmef_additional_data_t Also, I do not manage to get python integer values from the functions that return either an uint32_t* or uint16_t* type (e.g., get_severity, get_completion, userid->get_number, process->get_pid, get_completion, get_port, etc...). I get a reference to the corresponding object, but I cannot (or I don't know how to) dereference the pointer to get the value in python. My (dirty) workaround consists in replacing {{{ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_unsigned_int, 0 | 0 ); }}} with {{{ resultobj = PyInt_FromLong((long)(*result)); }}} in _prelude.c, after having tested that result is not NULL: {{{ if(result == (uint32_t *)NULL) SWIG_fail; }}} Maybe a typemap directive is also required here, but I am not sure... Cheers, Ben -- Ticket URL: <https://trac.prelude-ids.org/ticket/269#comment:4> Prelude Hybrid IDS <http://www.prelude-ids.org> The Prelude Hybrid Intrusion Detection System suite _______________________________________________ Prelude-devel site list [email protected] http://www.prelude-ids.org/mailman/listinfo/prelude-devel