mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 04:29:02 -04:00
Improvements for kore.recvmsg() in Python.
The cmsghdr contains a length (cmsg_len) which indicates the length of the data in combination with the cmsghdr length itself. Remove the length of the cmsghdr before passing it back up to callers so they don't need to bother with it. This also fixes a mistake where we ended up copying extra data from the ancdata buffer that was unintended.
This commit is contained in:
parent
5e47218ccd
commit
f7a76f7e96
@ -898,6 +898,7 @@ static PyObject *
|
||||
python_cmsg_to_list(struct msghdr *msg)
|
||||
{
|
||||
struct cmsghdr *c;
|
||||
size_t len;
|
||||
Py_ssize_t idx;
|
||||
PyObject *list, *tuple;
|
||||
|
||||
@ -907,8 +908,10 @@ python_cmsg_to_list(struct msghdr *msg)
|
||||
idx = 0;
|
||||
|
||||
for (c = CMSG_FIRSTHDR(msg); c != NULL; c = CMSG_NXTHDR(msg, c)) {
|
||||
tuple = Py_BuildValue("(Iiiy#)", c->cmsg_len,
|
||||
c->cmsg_level, c->cmsg_type, CMSG_DATA(c), c->cmsg_len);
|
||||
len = c->cmsg_len - sizeof(*c);
|
||||
|
||||
tuple = Py_BuildValue("(Iiiy#)", len,
|
||||
c->cmsg_level, c->cmsg_type, CMSG_DATA(c), len);
|
||||
|
||||
if (tuple == NULL) {
|
||||
Py_DECREF(list);
|
||||
|
Loading…
x
Reference in New Issue
Block a user