Revert "Improve compatibility with Python 3 SWIG bindings"
The patch introduced new issues and memory leaks.
This reverts commit cb8eded90a
.
This commit is contained in:
parent
cb8eded90a
commit
8b5abd72f1
@ -1,106 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
@ -5,8 +5,6 @@ Release: 3%{?dist}
|
|||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
Group: System Environment/Libraries
|
Group: System Environment/Libraries
|
||||||
Source: https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20150202/libsepol-%{version}.tar.gz
|
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
|
URL: https://github.com/SELinuxProject/selinux/wiki
|
||||||
BuildRequires: flex
|
BuildRequires: flex
|
||||||
|
|
||||||
@ -47,8 +45,6 @@ needed for developing applications that manipulate binary policies.
|
|||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
|
|
||||||
%patch0 -p1
|
|
||||||
|
|
||||||
# sparc64 is an -fPIC arch, so we need to fix it here
|
# sparc64 is an -fPIC arch, so we need to fix it here
|
||||||
%ifarch sparc64
|
%ifarch sparc64
|
||||||
sed -i 's/fpic/fPIC/g' src/Makefile
|
sed -i 's/fpic/fPIC/g' src/Makefile
|
||||||
|
Loading…
Reference in New Issue
Block a user