diff --git a/0002-Specify-prototypes-for-used-X11-C-functions.patch b/0002-Specify-prototypes-for-used-X11-C-functions.patch new file mode 100644 index 0000000..c03dedc --- /dev/null +++ b/0002-Specify-prototypes-for-used-X11-C-functions.patch @@ -0,0 +1,67 @@ +From a076837517074986ba4253d2dd8328356729ff20 Mon Sep 17 00:00:00 2001 +From: Jakub Filak +Date: Wed, 29 Jul 2015 14:23:34 +0200 +Subject: [PATCH] Specify prototypes for used X11 C functions + +Python does not magically resolve types of C functions imported through +ctypes. Without specifying their prototypes the return type of all +functions is c_int and all Python int arguments are converted to C int +arguments. + +The return type of XOpenDisplay is 'Display *', so the correct return type is +'c_void_p'. + +The argument type of XCloseDisplay is 'Display *', so the correct +argument type is 'c_void_p' too. + +Without this patch, the pointers returned from XOpenDisplay and passed +to XCloseDisplay are truncated to int, which is shorter than 'void *' on +some architectures, and that causes unpredicted behavior which leads to +a crash. + +Related: bugzilla.redhat.com/1244261 + +Signed-off-by: Jakub Filak +--- + src/fros | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +diff --git a/src/fros b/src/fros +index 56b4070..22a62b8 100755 +--- a/src/fros ++++ b/src/fros +@@ -19,7 +19,7 @@ + + + import sys +-from ctypes import cdll, util ++from ctypes import cdll, util, c_void_p, c_char_p + + XLIB_PATH = util.find_library('X11') + if not XLIB_PATH: +@@ -27,12 +27,20 @@ if not XLIB_PATH: + sys.exit(1) + + XLIB = cdll.LoadLibrary(XLIB_PATH) +-DISPLAY = XLIB.XOpenDisplay(None) ++ ++XOpenDisplay = XLIB.XOpenDisplay ++XOpenDisplay.argtypes = [c_char_p] ++XOpenDisplay.restype = c_void_p ++ ++DISPLAY = XOpenDisplay(None) + if DISPLAY == 0: + sys.stderr.write("Cannot connect to X server\n") + sys.exit(2) + +-XLIB.XCloseDisplay(DISPLAY) ++XCloseDisplay = XLIB.XCloseDisplay ++XCloseDisplay.argtypes = [c_void_p] ++ ++XCloseDisplay(DISPLAY) + + from pyfros.froslogging import error, info, set_verbosity + from pyfros.controls import Controls +-- +2.4.6 + diff --git a/fros.spec b/fros.spec index ae0d358..c57e0ba 100644 --- a/fros.spec +++ b/fros.spec @@ -1,6 +1,6 @@ Name: fros Version: 1.1 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Universal screencasting frontend with pluggable support for various backends %global commit 30275a07dab7891b9f31ff115743f67d757c7c1a @@ -13,7 +13,17 @@ URL: https://github.com/mozeq/fros Source: https://github.com/mozeq/fros/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +# git format-patch %%{commit} --topo-order -N -M; +#Patch0001: 0001-Update-the-spec-file-and-release-1.1.patch +# upstream pull request: https://github.com/mozeq/fros/pull/12 +Patch0002: 0002-Specify-prototypes-for-used-X11-C-functions.patch +#Patch0003: 0003-Add-Makefile-rules-for-building-rpm-from-local-repos.patch + BuildArch: noarch + +# '%%autosetup -S git' -> git +BuildRequires: git + BuildRequires: python3-devel BuildRequires: python3-setuptools @@ -42,7 +52,13 @@ Requires: %{name} = %{version}-%{release} fros plugin for screencasting using Gnome3 integrated screencaster %prep -%setup -qn %{name}-%{commit} +# If you need to use '--exclude' update __scm_apply_git_am as follows (don't +# forget to remove the second % from all macros): +#(see /usr/lib/rpm/macros for more details) +#%%define __scm_apply_git_am(qp:m:) %%{__git} am --exclude Makefile %%{-q} %%{-p:-p%%{-p*}} +# I am using "git_am" because "git" does not allow to create a new file within +# a patch because the scm "git" uses "git apply && git commit" +%autosetup -n %{name}-%{commit} -S git_am %build CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build @@ -64,7 +80,8 @@ CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build %{python3_sitelib}/pyfros/plugins/__init__.* %{python3_sitelib}/pyfros/plugins/const.* %dir %{python3_sitelib}/pyfros/plugins/__pycache__ -%{python3_sitelib}/pyfros/plugins/__pycache__/*.cpython-%{python3_version_nodots}.py* +%{python3_sitelib}/pyfros/plugins/__pycache__/__init__.cpython-%{python3_version_nodots}.py* +%{python3_sitelib}/pyfros/plugins/__pycache__/const.cpython-%{python3_version_nodots}.py* # fros-1.0-py2.7.egg-info %dir %{python3_sitelib}/%{name}-%{version}-py%{python3_version}.egg-info %{python3_sitelib}/%{name}-%{version}-py%{python3_version}.egg-info/* @@ -73,11 +90,18 @@ CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build %files recordmydesktop %{python3_sitelib}/pyfros/plugins/*recordmydesktop.* +%{python3_sitelib}/pyfros/plugins/__pycache__/*recordmydesktop.cpython-%{python3_version_nodots}.py* %files gnome %{python3_sitelib}/pyfros/plugins/*gnome.* +%{python3_sitelib}/pyfros/plugins/__pycache__/*gnome.cpython-%{python3_version_nodots}.py* %changelog +* Wed Jul 29 2015 Jakub Filak - 1.1-4 +- specify X11 C functions prototypes +- move byte compiled plugin files to plugin packages +- Resolves: #1244261 + * Wed Jun 17 2015 Fedora Release Engineering - 1.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild