Skip to content

Commit

Permalink
* bugfix #1399: ldns_pkt2wire() Python binding is broken.
Browse files Browse the repository at this point in the history
  Thanks James Raftery
  • Loading branch information
wcawijngaards committed Aug 11, 2017
1 parent 8d58244 commit 0e09396
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* ldns_wire2pkt: fix null pointer dereference if pkt allocation fails
and fix memory leak with more EDNS sections
Thanks Jan Vcelak
* bugfix #1399: ldns_pkt2wire() Python binding is broken.
Thanks James Raftery

1.7.0 2016-12-20
* Fix lookup of relative names in ldns_resolver_search.
Expand Down
25 changes: 25 additions & 0 deletions contrib/python/ldns.i
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,28 @@ PyObject* ldns_wire2pkt_(const char *str, int len)
return tuple;
}
PyObject* ldns_pkt2wire_(const ldns_pkt *pkt)
//returns tuple (status, result)
{
PyObject *resultobj = 0;
uint8_t *arg1 = NULL;
size_t arg3;
ldns_status result;
PyObject* tuple;
result = (ldns_status)ldns_pkt2wire(&arg1,pkt,&arg3);
tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, SWIG_From_int(result));
if (result == LDNS_STATUS_OK)
PyTuple_SetItem(tuple, 1, SWIG_FromCharPtrAndSize((char *)arg1, arg3));
else {
Py_INCREF(Py_None);
PyTuple_SetItem(tuple, 1, Py_None);
}
LDNS_FREE(arg1);
return tuple;
}
%}
%pythoncode %{
Expand All @@ -408,6 +430,9 @@ def ldns_fetch_valid_domain_keys(res, domain, keys):
def ldns_wire2pkt(data):
return _ldns.ldns_wire2pkt_(data)
def ldns_pkt2wire(data):
return _ldns.ldns_pkt2wire_(data)
def ldns_rr_iter_frm_fp_l(input_file):
"""Creates an iterator (generator) that returns individual parsed
RRs from an open zone file."""
Expand Down

0 comments on commit 0e09396

Please sign in to comment.