Merge pull request #26 from kti/25-Crash-in-iptables-OUTPUT-chain

25 crash in iptables output chain
This commit is contained in:
Matt Fox 2017-01-30 23:41:46 -08:00 committed by GitHub
commit db750b7212
5 changed files with 512 additions and 476 deletions

View File

@ -81,9 +81,8 @@ From source
To install from source::
wget https://pypi.python.org/packages/94/5b/83d10952c1312fe056f8f2f524a4a59fdc9d56b84a67cae1ed779e2da50b/NetfilterQueue-0.8.tar.gz#md5=8e78db992ad3a73dd86fef05293fff65
tar -xvzf NetfilterQueue-0.8.tar.gz
cd NetfilterQueue-0.8
git clone git@github.com:kti/python-netfilterqueue.git
cd python-netfilterqueue
python setup.py install
If Cython is installed, Distutils will use it to regenerate the .c source from the .pyx. It will then compile the .c into a .so.

View File

@ -3,6 +3,9 @@ from netfilterqueue import NetfilterQueue
def print_and_accept(pkt):
print(pkt)
hw = pkt.get_hw()
if hw:
print(":".join("{:02x}".format(ord(c)) for c in hw[0:6]))
pkt.accept()
nfqueue = NetfilterQueue()

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@ function.
Copyright: (c) 2011, Kerkhoff Technologies Inc.
License: MIT; see LICENSE.txt
"""
VERSION = (0, 8, 0)
VERSION = (0, 8, 1)
# Constants for module users
COPY_NONE = 0
@ -57,12 +57,10 @@ cdef class Packet:
self._qh = qh
self._nfa = nfa
self._hdr = nfq_get_msg_packet_hdr(nfa)
self._hw = nfq_get_packet_hw(nfa)
self.id = ntohl(self._hdr.packet_id)
self.hw_protocol = ntohs(self._hdr.hw_protocol)
self.hook = self._hdr.hook
self.hw_addr = self._hw.hw_addr
self.payload_len = nfq_get_payload(self._nfa, &self.payload)
if self.payload_len < 0:
@ -101,6 +99,11 @@ cdef class Packet:
def get_hw(self):
"""Return the hardware address as Python string."""
self._hw = nfq_get_packet_hw(self._nfa)
if self._hw == NULL:
# nfq_get_packet_hw doesn't work on OUTPUT and PREROUTING chains
return None
self.hw_addr = self._hw.hw_addr
cdef object py_string
if cpython.version.PY_MAJOR_VERSION >= 3:
py_string = PyBytes_FromStringAndSize(<char*>self.hw_addr, 8)

View File

@ -1,6 +1,6 @@
from distutils.core import setup, Extension
VERSION = "0.8" # Remember to change README.rst and netfilterqueue.pyx when version changes.
VERSION = "0.8.1" # Remember to change netfilterqueue.pyx when version changes.
try:
# Use Cython