Skip to content

Packet.drop_refs() and self.payload pointer #88

@DOWRIGHTTV

Description

@DOWRIGHTTV
packet.set_nfq_data(nfqueue, nfa)
try:
    user_callback(packet)
finally:
    packet.drop_refs()
return 1

the drop_refs call is setting a pointer to null, but doesnt touch the actual memory allocated by libnetfilter_queue. the pointer will also be garbage collected once it Packet is no longer referenced. I feel this should be removed, but if it needs to be there for something i am not seeing, then it can be moved to a dealloc method and done automatically. (both of these get messy though if python kills it before you get to it)

self.payload_len = nfq_get_payload(nfa, &self.payload)
if self.payload_len < 0:
    # Probably using a mode that doesn't provide the payload
    self.payload = NULL
    self.payload_len = 0

this has a similar issue. i would expect this code would never be reached , but if so it doesnt need to reset the payload pointer. nfq_get_payload returning -1 is due to an error, so it would probably be more fitting to raise that up or exit since it is likely a fatal condition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions