Package: pcapy Version: 0.11.5-3 Severity: important Tags: patch Dear Maintainer,
I submitted a patch to fix the PythonCallBack function. Bug reproduction: When installing python3-pcapy in the environment of python3.12 and using the loop function of the pcapy module, the following error message will be reported. $ sudo python3 test.py Traceback (most recent call last): File "/home/txf/workdir/test.py", line 8, in <module> cap.loop(0, packet_handler) TypeError: packet_handler() missing 2 required positional arguments: 'header' and 'data' Cause analysis: The len pointer in the PythonCallBack function is of type (Py_stsize_t *), pointing to (&header ->caplen). The caplen variable is of 4-byte type (unsigned int), while Py_Ssize_t is of 8-byte type. The above code will cause the * len variable to read 8 bytes of memory, resulting in a logical error in the code. The final result is arglist=Py_SuildValue ("Oy #", hdr, packtdata, * len); Execution error. My repair suggestion is to change the (* len) variable type in the PythonCallBack function to (unsigned int *). Here are my test scripts and patch fixes. I am using Linux, 6.11.0-24-generic and libc6 2.39. The patch has been tested on Debian bookworm and works correctly. Thank you for considering this contribution. Best regards, Xiaofeng Tang tangxiaof...@kylinos.cn
fix_PythonCallBack.patch
Description: Binary data
test.py
Description: Binary data