Date: Tuesday, December 15, 2015 @ 01:28:51 Author: anthraxx Revision: 153332
upgpkg: tlsh 3.4.4-1 addpkg: tlsh 3.4.4-1 Added: tlsh/trunk/fix-python3.patch -------------------+ fix-python3.patch | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) Added: fix-python3.patch =================================================================== --- fix-python3.patch (rev 0) +++ fix-python3.patch 2015-12-15 00:28:51 UTC (rev 153332) @@ -0,0 +1,35 @@ +From 243124159ad0fcbbb1329100c233bbfae40ca0de Mon Sep 17 00:00:00 2001 +From: anthraxx <[email protected]> +Date: Sat, 5 Dec 2015 21:56:21 +0100 +Subject: [PATCH] convert arg to bytes object before passing to + PyBytes_AsStringAndSize + +this fixes python3 and ensures for both, python2 and python3 that +the passed argument is a string. +--- + py_ext/tlshmodule.cpp | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/py_ext/tlshmodule.cpp b/py_ext/tlshmodule.cpp +index 409501b..8ed2335 100644 +--- a/py_ext/tlshmodule.cpp ++++ b/py_ext/tlshmodule.cpp +@@ -178,6 +178,18 @@ Tlsh_fromTlshStr(tlsh_TlshObject *self, PyObject *args) + return PyErr_Format(PyExc_TypeError, "function takes exactly 1 argument (%lu given)", PyTuple_Size(args)); + + arg = PyTuple_GetItem(args, 0); ++#if PY_MAJOR_VERSION >= 3 ++ if (!PyUnicode_Check(arg) || (arg = PyUnicode_AsASCIIString(arg)) == NULL) { ++ PyErr_SetString(PyExc_ValueError, "argument is not a TLSH hex string"); ++ return NULL; ++ } ++#else ++ if (!PyString_Check(arg)) { ++ PyErr_SetString(PyExc_ValueError, "argument is not a TLSH hex string"); ++ return NULL; ++ } ++#endif ++ + if (PyBytes_AsStringAndSize(arg, &str, &len) == -1) { + PyErr_SetString(PyExc_ValueError, "argument is not a TLSH hex string"); + return NULL;
