diff --git a/swig-2.0.4-fix-overflow-error-64bitint.patch b/swig-2.0.4-fix-overflow-error-64bitint.patch new file mode 100644 index 0000000..8ad0b10 --- /dev/null +++ b/swig-2.0.4-fix-overflow-error-64bitint.patch @@ -0,0 +1,80 @@ +Description: Fix overflow errors with 64-bit IVs + The perl 5.12 packages are compiled with -Duse64bitint, which means that IVs + are 64-bits even on 32-bit architectures. When converting IVs, SWIG assumes + that an IV is the same size as a long, which causes OverflowErrors with + unsigned longs when the value is greater than 2^31. + . + This patch should remove those assumptions by using the "IV" type defined by + the perl headers, and explicitly checking the values are within the correct + range for the type being converted. +Author: Chris Butler +Bug-Debian: http://bugs.debian.org/579540 +Forwarded: no + +--- a/Lib/perl5/perlprimtypes.swg ++++ b/Lib/perl5/perlprimtypes.swg +@@ -56,8 +56,13 @@ + SWIG_AsVal_dec(long)(SV *obj, long* val) + { + if (SvIOK(obj)) { +- if (val) *val = SvIV(obj); +- return SWIG_OK; ++ IV v = SvIV(obj); ++ if (v >= LONG_MIN && v <= LONG_MAX) { ++ if (val) *val = v; ++ return SWIG_OK; ++ } else { ++ return SWIG_OverflowError; ++ } + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); +@@ -108,11 +113,16 @@ + SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val) + { + if (SvUOK(obj)) { +- if (val) *val = SvUV(obj); +- return SWIG_OK; ++ UV v = SvUV(obj); ++ if (v >= 0 && v <= ULONG_MAX) { ++ if (val) *val = v; ++ return SWIG_OK; ++ } else { ++ return SWIG_OverflowError; ++ } + } else if (SvIOK(obj)) { +- long v = SvIV(obj); +- if (v >= 0) { ++ IV v = SvIV(obj); ++ if (v >= 0 && v <= ULONG_MAX) { + if (val) *val = v; + return SWIG_OK; + } else { +@@ -179,8 +189,13 @@ + SWIG_AsVal_dec(long long)(SV *obj, long long *val) + { + if (SvIOK(obj)) { +- if (val) *val = SvIV(obj); +- return SWIG_OK; ++ IV v = SvIV(obj); ++ if (v >= LLONG_MIN && v <= LLONG_MAX) { ++ if (val) *val = v; ++ return SWIG_OK; ++ } else { ++ return SWIG_OverflowError; ++ } + } else { + int dispatch = 0; + const char *nptr = SvPV_nolen(obj); +@@ -246,8 +261,8 @@ + if (val) *val = SvUV(obj); + return SWIG_OK; + } else if (SvIOK(obj)) { +- long v = SvIV(obj); +- if (v >= 0) { ++ IV v = SvIV(obj); ++ if (v >= 0 && v <= ULLONG_MAX) { + if (val) *val = v; + return SWIG_OK; + } else { + diff --git a/swig.changes b/swig.changes index e877b91..e0eccd9 100644 --- a/swig.changes +++ b/swig.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Tue Mar 6 19:24:07 UTC 2012 - dvaleev@suse.com + +- The perl 5.12 packages are compiled with -Duse64bitint, which + means that IVs are 64-bits even on 32-bit architectures. When + converting IVs, SWIG assumes that an IV is the same size as a + long, which causes OverflowErrors with unsigned longs when + the value is greater than 2^31. + ------------------------------------------------------------------- Tue Mar 6 09:15:47 UTC 2012 - kkaempf@suse.com diff --git a/swig.spec b/swig.spec index 23fb304..09656f9 100644 --- a/swig.spec +++ b/swig.spec @@ -67,6 +67,7 @@ Patch3: swig-2.0.4-disable-broken-tests.patch Patch4: swig-2.0.4-disable-broken-tests_rhel4.patch # PATCH-FIX-UPSTREAM swig-2.0.4-guile2.patch pgajdos@suse.com -- generate guile 2 friendly code Patch5: swig-2.0.4-guile2.patch +Patch6: swig-2.0.4-fix-overflow-error-64bitint.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -131,6 +132,7 @@ understandig SWIG usage. %if 0%{?suse_version} >= 1210 %patch5 -p1 %endif +%patch6 -p1 %build %configure --disable-ccache