Fixes for bad castings on exhotic platfroms
Backported from upstream
This commit is contained in:
parent
1a0ebcd437
commit
2a1dd4d16d
38
0001-Fix-generators-for-parsing-of-integer-values.patch
Normal file
38
0001-Fix-generators-for-parsing-of-integer-values.patch
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
From 0caa4e7b254b26d418048191aa588c6696a55a4d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Simo Sorce <simo@redhat.com>
|
||||||
|
Date: Thu, 17 Apr 2014 18:10:31 -0400
|
||||||
|
Subject: [PATCH 1/2] Fix generators for parsing of integer values
|
||||||
|
|
||||||
|
All number types including enums are parse as if they were integers,
|
||||||
|
this breaks in many ways, long and int are not the same size in all
|
||||||
|
architectures as well as enum may vary in size depening on compiler,
|
||||||
|
architecture and optimizations.
|
||||||
|
|
||||||
|
Always pass an actual long to PyArg_ParseTuple() and rely on the a
|
||||||
|
cast from long to the destination variable type in the following
|
||||||
|
assignment.
|
||||||
|
|
||||||
|
Signed-off-by: Simo Sorce <simo@redhat.com>
|
||||||
|
---
|
||||||
|
bindings/python/lang.py | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bindings/python/lang.py b/bindings/python/lang.py
|
||||||
|
index f5c9d36ec6bd4550a8edd4ba93e5f4862bd40139..c695518e5a553738f11d614c9ce98953338408b7 100644
|
||||||
|
--- a/bindings/python/lang.py
|
||||||
|
+++ b/bindings/python/lang.py
|
||||||
|
@@ -770,9 +770,9 @@ register_constants(PyObject *d)
|
||||||
|
parse_arg = '&value'
|
||||||
|
print >> fd, ' %s value;' % type
|
||||||
|
elif is_int(m, self.binding_data):
|
||||||
|
- parse_format = 'i'
|
||||||
|
+ parse_format = 'l'
|
||||||
|
parse_arg = '&value'
|
||||||
|
- print >> fd, ' %s value;' % type
|
||||||
|
+ print >> fd, ' long value;'
|
||||||
|
elif is_glist(m) or is_hashtable(m) or is_xml_node(m) or is_boolean(m):
|
||||||
|
parse_format = 'O'
|
||||||
|
print >> fd, ' PyObject *cvt_value;'
|
||||||
|
--
|
||||||
|
1.9.0
|
||||||
|
|
108
0002-xml-xml.c-fix-liberal-use-of-casting-for-the-SNIPPET.patch
Normal file
108
0002-xml-xml.c-fix-liberal-use-of-casting-for-the-SNIPPET.patch
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
From 53c4298876331c1312a9a0f4dbe6eb28b2dbea59 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Benjamin Dauvergne <bdauvergne@entrouvert.com>
|
||||||
|
Date: Thu, 24 Apr 2014 01:30:49 +0200
|
||||||
|
Subject: [PATCH 2/2] xml/xml.c: fix liberal use of casting for the
|
||||||
|
SNIPPET_INTEGER and SNIPPET_BOOLEAN case
|
||||||
|
|
||||||
|
Some behaviour are also made more explicit like the optional if equals
|
||||||
|
to -1 case for integer fields, and the optional if FALSE for boolean
|
||||||
|
fields.
|
||||||
|
---
|
||||||
|
lasso/xml/xml.c | 55 ++++++++++++++++++++++++++++++++++---------------------
|
||||||
|
1 file changed, 34 insertions(+), 21 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
|
||||||
|
index ba207f552cf5c6a587c1866adecab9f2ac9a339a..4485d47669deb5b15c3f3cbcfec98942bd2edbf6 100644
|
||||||
|
--- a/lasso/xml/xml.c
|
||||||
|
+++ b/lasso/xml/xml.c
|
||||||
|
@@ -2717,7 +2717,6 @@ lasso_node_build_xmlNode_from_snippets(LassoNode *node, LassoNodeClass *class, x
|
||||||
|
struct XmlSnippet *snippets, gboolean lasso_dump)
|
||||||
|
{
|
||||||
|
struct XmlSnippet *snippet;
|
||||||
|
- SnippetType type;
|
||||||
|
GType g_type;
|
||||||
|
xmlNode *t;
|
||||||
|
GList *elem;
|
||||||
|
@@ -2727,36 +2726,49 @@ lasso_node_build_xmlNode_from_snippets(LassoNode *node, LassoNodeClass *class, x
|
||||||
|
|
||||||
|
for (snippet = snippets; snippet && snippet->name; snippet++) {
|
||||||
|
void *value;
|
||||||
|
+ int int_value;
|
||||||
|
+ gboolean bool_value;
|
||||||
|
char *str;
|
||||||
|
+ gboolean optional = snippet->type & SNIPPET_OPTIONAL;
|
||||||
|
+ gboolean optional_neg = snippet->type & SNIPPET_OPTIONAL_NEG;
|
||||||
|
|
||||||
|
if (! snippet->offset && ! (snippet->type & SNIPPET_PRIVATE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
- type = snippet->type & 0xff;
|
||||||
|
- value = SNIPPET_STRUCT_MEMBER(void *, node, g_type, snippet);
|
||||||
|
- str = value;
|
||||||
|
- if (lasso_dump == FALSE && snippet->type & SNIPPET_LASSO_DUMP)
|
||||||
|
+ if (lasso_dump == FALSE && snippet->type & SNIPPET_LASSO_DUMP) {
|
||||||
|
continue;
|
||||||
|
-
|
||||||
|
- if (type == SNIPPET_ATTRIBUTE && snippet->type & SNIPPET_ANY) {
|
||||||
|
+ }
|
||||||
|
+ if ((snippet->type & 0xff) == SNIPPET_ATTRIBUTE && (snippet->type & SNIPPET_ANY)) {
|
||||||
|
snippet_any_attribute = snippet;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
- if (value == NULL && (!(snippet->type & SNIPPET_BOOLEAN ||
|
||||||
|
- snippet->type & SNIPPET_INTEGER) ||
|
||||||
|
- snippet->type & SNIPPET_OPTIONAL))
|
||||||
|
- continue;
|
||||||
|
|
||||||
|
- if (snippet->type & SNIPPET_OPTIONAL_NEG && GPOINTER_TO_INT(value) == -1)
|
||||||
|
- continue;
|
||||||
|
+ // convert input type to string if needed
|
||||||
|
+ if (snippet->type & SNIPPET_INTEGER) {
|
||||||
|
+ int_value = SNIPPET_STRUCT_MEMBER(int, node, g_type, snippet);
|
||||||
|
+ if (int_value == 0 && optional) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (int_value == -1 && optional_neg) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ str = g_strdup_printf("%i", int_value);
|
||||||
|
+ } else if (snippet->type & SNIPPET_BOOLEAN) {
|
||||||
|
+ bool_value = SNIPPET_STRUCT_MEMBER(gboolean, node, g_type, snippet);
|
||||||
|
+ if (bool_value == FALSE && optional) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ str = bool_value ? "true" : "false";
|
||||||
|
+ } else {
|
||||||
|
+ value = SNIPPET_STRUCT_MEMBER(void *, node, g_type, snippet);
|
||||||
|
+ if (value == NULL) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ str = value;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- /* XXX: not sure it is 64-bits clean */
|
||||||
|
- if (snippet->type & SNIPPET_BOOLEAN)
|
||||||
|
- str = GPOINTER_TO_INT(value) ? "true" : "false";
|
||||||
|
- if (snippet->type & SNIPPET_INTEGER)
|
||||||
|
- str = g_strdup_printf("%d", GPOINTER_TO_INT(value));
|
||||||
|
-
|
||||||
|
- switch (type) {
|
||||||
|
+ // output type
|
||||||
|
+ switch (snippet->type & 0xff) {
|
||||||
|
case SNIPPET_ATTRIBUTE:
|
||||||
|
if (snippet->ns_name) {
|
||||||
|
xmlNsPtr ns;
|
||||||
|
@@ -2840,8 +2852,9 @@ lasso_node_build_xmlNode_from_snippets(LassoNode *node, LassoNodeClass *class, x
|
||||||
|
case SNIPPET_UNUSED1:
|
||||||
|
g_assert_not_reached();
|
||||||
|
}
|
||||||
|
- if (snippet->type & SNIPPET_INTEGER)
|
||||||
|
+ if (snippet->type & SNIPPET_INTEGER) {
|
||||||
|
lasso_release(str);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (snippet_any_attribute) {
|
||||||
|
--
|
||||||
|
1.9.0
|
||||||
|
|
10
lasso.spec
10
lasso.spec
@ -11,7 +11,7 @@
|
|||||||
Summary: Liberty Alliance Single Sign On
|
Summary: Liberty Alliance Single Sign On
|
||||||
Name: lasso
|
Name: lasso
|
||||||
Version: 2.4.0
|
Version: 2.4.0
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: System Environment/Libraries
|
Group: System Environment/Libraries
|
||||||
Source: http://dev.entrouvert.org/lasso/lasso-%{version}.tar.gz
|
Source: http://dev.entrouvert.org/lasso/lasso-%{version}.tar.gz
|
||||||
@ -24,6 +24,8 @@ BuildRequires: libxml2-devel, xmlsec1-devel, openssl-devel, xmlsec1-openssl-deve
|
|||||||
Url: http://lasso.entrouvert.org/
|
Url: http://lasso.entrouvert.org/
|
||||||
|
|
||||||
Patch01: 0001-Fix-java-version-detection.patch
|
Patch01: 0001-Fix-java-version-detection.patch
|
||||||
|
Patch02: 0001-Fix-generators-for-parsing-of-integer-values.patch
|
||||||
|
Patch03: 0002-xml-xml.c-fix-liberal-use-of-casting-for-the-SNIPPET.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Lasso is a library that implements the Liberty Alliance Single Sign On
|
Lasso is a library that implements the Liberty Alliance Single Sign On
|
||||||
@ -100,6 +102,8 @@ library.
|
|||||||
%prep
|
%prep
|
||||||
%setup -q -n %{name}-%{version}
|
%setup -q -n %{name}-%{version}
|
||||||
%patch01 -p1 -b .java_version
|
%patch01 -p1 -b .java_version
|
||||||
|
%patch02 -p1 -b .generators
|
||||||
|
%patch03 -p1 -b .xml_casts
|
||||||
|
|
||||||
%build
|
%build
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
@ -202,6 +206,10 @@ rm -fr %{buildroot}%{_defaultdocdir}/%{name}
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Apr 25 2014 Simo Sorce <simo@redhat.com> - 2.4.0-2
|
||||||
|
- Fixes for arches where pointers and integers do not have the same size
|
||||||
|
(ppc64, s390, etc..)
|
||||||
|
|
||||||
* Mon Apr 14 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 2.4.0-1
|
* Mon Apr 14 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 2.4.0-1
|
||||||
- Use OpenJDK instead of GCJ for java bindings
|
- Use OpenJDK instead of GCJ for java bindings
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user