-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk/I+5AACgkQrlYvE4MpobOCgACcC7MvZmLU93HKaMsFE7hicHxp XTQAn0kYbyxP3KXzi0CypzPt5aiMLwR7 =w3lB -----END PGP SIGNATURE-----
>From 910b5440a69dbdbcf003b4bb0aa0ddbd704325e7 Mon Sep 17 00:00:00 2001 From: Dan Walsh <dwalsh@xxxxxxxxxx> Date: Tue, 29 May 2012 11:12:11 -0400 Subject: [PATCH 76/90] Sven Vermeulen patch for python3.2 support. """ David Malcolm gave me a good hint at what to look for. The key that is created contains a link towards a regular expression (in the above use case, that expression would be "/swapfile") which is passed on from the Python code towards the shared library (through semanage_fcontext_key_create). I think that, in Python 2.7, the memory allocation for this expression is either not freed at the same time as with Python 3.2, or it is freed but not reused (in which case the stale information is still there). If I apply the following patch to libsemanage, the use case works for both Python 2.7 and Python 3.2. Wkr, Sven Vermeulen """ --- libsemanage/src/fcontext_record.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libsemanage/src/fcontext_record.c b/libsemanage/src/fcontext_record.c index ec02a89..3d28f9c 100644 --- a/libsemanage/src/fcontext_record.c +++ b/libsemanage/src/fcontext_record.c @@ -25,7 +25,7 @@ struct semanage_fcontext { struct semanage_fcontext_key { /* Matching expression */ - const char *expr; + char *expr; /* Type of object */ int type; @@ -45,7 +45,11 @@ int semanage_fcontext_key_create(semanage_handle_t * handle, "create file context key"); return STATUS_ERR; } - tmp_key->expr = expr; + tmp_key->expr = strdup(expr); + if (!tmp_key->expr) { + ERR(handle, "out of memory, could not create file context key."); + return STATUS_ERR; + } tmp_key->type = type; *key_ptr = tmp_key; @@ -74,6 +78,7 @@ hidden_def(semanage_fcontext_key_extract) void semanage_fcontext_key_free(semanage_fcontext_key_t * key) { + free(key->expr); free(key); } -- 1.7.10.2