From 5c210817cf113e35cf833adb3016bfdfd27eb8b6 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 4 Mar 2016 17:24:38 +0000 Subject: [PATCH] Fix a Python bindings crash on 64-bit systems (#1296817) --- libproxy-0.4.12-fix-python-crash.patch | 37 ++++++++++++++++++++++++++ libproxy.spec | 8 +++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 libproxy-0.4.12-fix-python-crash.patch diff --git a/libproxy-0.4.12-fix-python-crash.patch b/libproxy-0.4.12-fix-python-crash.patch new file mode 100644 index 0000000..59e75ca --- /dev/null +++ b/libproxy-0.4.12-fix-python-crash.patch @@ -0,0 +1,37 @@ +From 76b89df0efc0fe817d320b7b34b2b0530ffd5538 Mon Sep 17 00:00:00 2001 +From: David King +Date: Fri, 4 Mar 2016 14:19:29 +0000 +Subject: [PATCH] python: Avoid a crash on 64-bit systems + +Annotate the return type of px_proxy_factory_new() to be void *, as otherwise +int is assumed. This works fine on 32-bit systems, where void * and int are the +same width, but is invalid on 64-bit (Linux) systems. + +Additionally, annotate the argument type of free() and px_proxy_factory_free() +to be void * to match. + +https://code.google.com/archive/p/libproxy/issues/146 +--- + bindings/python/libproxy.py | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/bindings/python/libproxy.py b/bindings/python/libproxy.py +index cb75a4d..7bddba9 100644 +--- a/bindings/python/libproxy.py ++++ b/bindings/python/libproxy.py +@@ -40,8 +40,12 @@ if platform.system() == "Windows": + else: + _libc = _load("c", 6) + ++_libc.free.argtypes = ctypes.c_void_p, ++ + # Load libproxy + _libproxy = _load("proxy", 1) ++_libproxy.px_proxy_factory_new.restype = ctypes.POINTER(ctypes.c_void_p) ++_libproxy.px_proxy_factory_free.argtypes = ctypes.c_void_p, + _libproxy.px_proxy_factory_get_proxies.restype = ctypes.POINTER(ctypes.c_void_p) + + class ProxyFactory(object): +-- +2.7.2 + diff --git a/libproxy.spec b/libproxy.spec index 1554432..8bd5f2d 100644 --- a/libproxy.spec +++ b/libproxy.spec @@ -4,7 +4,7 @@ Name: libproxy Version: 0.4.12 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A library handling all the details of proxy configuration Group: System Environment/Libraries @@ -19,6 +19,8 @@ Patch0: 0001-Add-config-module-for-querying-PacRunner-d-mon.patch Patch1: libproxy-0.4.12-javascriptcoregtk4.patch Patch2: libproxy-0.4.12-use-correct-delete.patch Patch3: libproxy-0.4.12-fix-kde-slowdown.patch +# Fix a Python bindings crash on 64-bit systems. +Patch4: libproxy-0.4.12-fix-python-crash.patch BuildRequires: python2-devel BuildRequires: libmodman-devel >= 2.0.1 @@ -152,6 +154,7 @@ developing applications that use %{name}. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 %build %{cmake} \ @@ -227,6 +230,9 @@ make test %changelog +* Fri Mar 04 2016 David King - 0.4.12-2 +- Fix a Python bindings crash on 64-bit systems (#1296817) + * Mon Feb 29 2016 David King - 0.4.12-1 - Update to 0.4.12 - Simplify conditional macros