Improve compatibility with Python 3 SWIG bindings
- Resolves: rhbz#1247714
This commit is contained in:
parent
cc880287e2
commit
cb8eded90a
106
0001-Improve-compatibility-with-Python-3-SWIG-bindings.patch
Normal file
106
0001-Improve-compatibility-with-Python-3-SWIG-bindings.patch
Normal file
@ -0,0 +1,106 @@
|
||||
From 50b3a9f3485ac7083a6c3f4cce75e504960cc036 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Srb <msrb@redhat.com>
|
||||
Date: Tue, 25 Aug 2015 10:14:41 +0200
|
||||
Subject: [PATCH] Improve compatibility with Python 3 SWIG bindings
|
||||
|
||||
Python 3 SWIG bindings temporarily allocate memory needed for
|
||||
PyUnicodeObject->char * conversion. This memory is deallocated shortly
|
||||
after underlying C function returns. Therefore it's necessary to create
|
||||
a copy of it.
|
||||
---
|
||||
src/boolean_record.c | 7 +++++--
|
||||
src/iface_record.c | 7 +++++--
|
||||
src/user_record.c | 7 +++++--
|
||||
3 files changed, 15 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/boolean_record.c b/src/boolean_record.c
|
||||
index 8b64413..0d139ac 100644
|
||||
--- a/src/boolean_record.c
|
||||
+++ b/src/boolean_record.c
|
||||
@@ -25,12 +25,14 @@ int sepol_bool_key_create(sepol_handle_t * handle,
|
||||
sepol_bool_key_t *tmp_key =
|
||||
(sepol_bool_key_t *) malloc(sizeof(struct sepol_bool_key));
|
||||
|
||||
- if (!tmp_key) {
|
||||
+ char *tmp_name = strdup(name);
|
||||
+
|
||||
+ if (!tmp_key || !tmp_name) {
|
||||
ERR(handle, "out of memory, " "could not create boolean key");
|
||||
return STATUS_ERR;
|
||||
}
|
||||
|
||||
- tmp_key->name = name;
|
||||
+ tmp_key->name = tmp_name;
|
||||
|
||||
*key_ptr = tmp_key;
|
||||
return STATUS_SUCCESS;
|
||||
@@ -62,6 +64,7 @@ int sepol_bool_key_extract(sepol_handle_t * handle,
|
||||
|
||||
void sepol_bool_key_free(sepol_bool_key_t * key)
|
||||
{
|
||||
+ free(key->name);
|
||||
free(key);
|
||||
}
|
||||
|
||||
diff --git a/src/iface_record.c b/src/iface_record.c
|
||||
index 09adeb7..4315238 100644
|
||||
--- a/src/iface_record.c
|
||||
+++ b/src/iface_record.c
|
||||
@@ -31,12 +31,14 @@ int sepol_iface_key_create(sepol_handle_t * handle,
|
||||
sepol_iface_key_t *tmp_key =
|
||||
(sepol_iface_key_t *) malloc(sizeof(sepol_iface_key_t));
|
||||
|
||||
- if (!tmp_key) {
|
||||
+ char *tmp_name = strdup(name);
|
||||
+
|
||||
+ if (!tmp_key || !tmp_name) {
|
||||
ERR(handle, "out of memory, could not create interface key");
|
||||
return STATUS_ERR;
|
||||
}
|
||||
|
||||
- tmp_key->name = name;
|
||||
+ tmp_key->name = tmp_name;
|
||||
|
||||
*key_ptr = tmp_key;
|
||||
return STATUS_SUCCESS;
|
||||
@@ -68,6 +70,7 @@ int sepol_iface_key_extract(sepol_handle_t * handle,
|
||||
|
||||
void sepol_iface_key_free(sepol_iface_key_t * key)
|
||||
{
|
||||
+ free(key->name);
|
||||
free(key);
|
||||
}
|
||||
|
||||
diff --git a/src/user_record.c b/src/user_record.c
|
||||
index c59c54b..dfc66e5 100644
|
||||
--- a/src/user_record.c
|
||||
+++ b/src/user_record.c
|
||||
@@ -34,13 +34,15 @@ int sepol_user_key_create(sepol_handle_t * handle,
|
||||
sepol_user_key_t *tmp_key =
|
||||
(sepol_user_key_t *) malloc(sizeof(sepol_user_key_t));
|
||||
|
||||
- if (!tmp_key) {
|
||||
+ char *tmp_name = strdup(name);
|
||||
+
|
||||
+ if (!tmp_key || !tmp_name) {
|
||||
ERR(handle, "out of memory, "
|
||||
"could not create selinux user key");
|
||||
return STATUS_ERR;
|
||||
}
|
||||
|
||||
- tmp_key->name = name;
|
||||
+ tmp_key->name = tmp_name;
|
||||
|
||||
*key_ptr = tmp_key;
|
||||
return STATUS_SUCCESS;
|
||||
@@ -71,6 +73,7 @@ int sepol_user_key_extract(sepol_handle_t * handle,
|
||||
|
||||
void sepol_user_key_free(sepol_user_key_t * key)
|
||||
{
|
||||
+ free(key->name);
|
||||
free(key);
|
||||
}
|
||||
|
||||
--
|
||||
2.4.3
|
||||
|
@ -1,10 +1,12 @@
|
||||
Summary: SELinux binary policy manipulation library
|
||||
Name: libsepol
|
||||
Version: 2.4
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
License: LGPLv2+
|
||||
Group: System Environment/Libraries
|
||||
Source: https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20150202/libsepol-%{version}.tar.gz
|
||||
# fix rhbz#1247714
|
||||
Patch0: 0001-Improve-compatibility-with-Python-3-SWIG-bindings.patch
|
||||
URL: https://github.com/SELinuxProject/selinux/wiki
|
||||
BuildRequires: flex
|
||||
|
||||
@ -45,6 +47,8 @@ needed for developing applications that manipulate binary policies.
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%patch0 -p1
|
||||
|
||||
# sparc64 is an -fPIC arch, so we need to fix it here
|
||||
%ifarch sparc64
|
||||
sed -i 's/fpic/fPIC/g' src/Makefile
|
||||
@ -101,6 +105,10 @@ exit 0
|
||||
%{_libdir}/libsepol.so.1
|
||||
|
||||
%changelog
|
||||
* Tue Aug 25 2015 Michal Srb <msrb@redhat.com> - 2.4-3
|
||||
- Improve compatibility with Python 3 SWIG bindings
|
||||
- Resolves: rhbz#1247714
|
||||
|
||||
* Fri Aug 14 2015 Adam Jackson <ajax@redhat.com> 2.4-2
|
||||
- Pass ldflags to make so hardening works
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user