OWASP / pysap

pysap is an open source Python library that provides modules for crafting and sending packets using SAP's NI, Diag, Enqueue, Router, MS, SNC, IGS, RFC and HDB protocols.
https://owasp.org/www-project-core-business-application-security/
GNU General Public License v2.0
220 stars 61 forks source link

Make pysapcompress compatible with Python 3.10 #39

Closed tp-sy closed 2 years ago

tp-sy commented 2 years ago

CPython code in pysapcompress.cpp needed some changes to be compatible with python 3.10.

Python 3.10 now requires the PY_SSIZE_T_CLEAN macro to be defined when using PyArg_ParseTuple() with "s#" format, which makes it always return a Py_ssize_t type instead of int. (see: https://docs.python.org/3/whatsnew/3.10.html#id2 and https://peps.python.org/pep-0353/). If the macro isn't defined the program crashes with

SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

Checking the size of the length arguments and then converting them to int type is enough to fix the issue.

martingalloar commented 2 years ago

Got it working on both Python 3.8 as well as Python 3.10. Thanks @tp-sy!