#1104437 [PATCH] Fix PythonCallBack function error in pcapy

Package:
pcapy
Source:
pcapy
Submitter:
tangxiaofeng@kylinos.cn
Date:
2026-10-19 11:23:02 UTC
Severity:
normal
Tags:
#1104437#5
Date:
2025-04-30 07:03:21 UTC
From:
To:
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



tangxiaofeng@kylinos.cn

#1104437#10
Date:
2026-10-19 11:21:10 UTC
From:
To:
Dear submitter,

as the package pcapy has just been removed from the Debian archive
unstable we hereby close the associated bug reports.  We are sorry
that we couldn't deal with your issue properly.

For details on the removal, please see https://bugs.debian.org/1150852

The version of this package that was in Debian prior to this removal
can still be found using https://snapshot.debian.org/.

Please note that the changes have been done on the master archive and
will not propagate to any mirrors until the next dinstall run at the
earliest.

This message was generated automatically; if you believe that there is
a problem with it please contact the archive administrators by mailing
ftpmaster@ftp-master.debian.org.

Debian distribution maintenance software
pp.
Thorsten Alteholz (the ftpmaster behind the curtain)