From ca5eda9ee287e86155a2de11af6d311839562e95 Mon Sep 17 00:00:00 2001 From: Petr Písař Date: Feb 24 2017 13:49:37 +0000 Subject: Fix constructing BSON::Time objects on 32-bit perl --- diff --git a/BSON-v1.2.2-Do-not-produce-Math-BigFloat-by-BSON-Time.patch b/BSON-v1.2.2-Do-not-produce-Math-BigFloat-by-BSON-Time.patch new file mode 100644 index 0000000..129199a --- /dev/null +++ b/BSON-v1.2.2-Do-not-produce-Math-BigFloat-by-BSON-Time.patch @@ -0,0 +1,62 @@ +From 8880ecb3084e6a4ed8cd37ea8b6701d8cd2987ef Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Fri, 24 Feb 2017 14:02:28 +0100 +Subject: [PATCH] Do not produce Math::BigFloat by BSON::Time +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Tests failed on 32-bit Perl without 64-bit intergers: + +During encode_one, Don't know how to encode Math::BigFloat '151109408000' as an Int64. at /builddir/build/BUILD/BSON-v1.2.2/blib/lib/BSON.pm line 299. + at t/legacy/10-bson.t line 385. + +That was caused by BSON::Time returning Math::BigFloat instead of +Math::BigInt. And as consequence BSON::PP::_pack_int64() bailed out +because it does not support Math::BigFloat. + +The issue was that Math::BigFloat->int() does not return Math::BigInt. +It still returns Math::BigFloat. This patch fixes by calling +as_number() that does so. + + + +Signed-off-by: Petr Písař +--- + lib/BSON/Time.pm | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/lib/BSON/Time.pm b/lib/BSON/Time.pm +index bf10583..4f874a9 100644 +--- a/lib/BSON/Time.pm ++++ b/lib/BSON/Time.pm +@@ -43,7 +43,7 @@ sub BUILDARGS { + else { + $args{value} = Math::BigFloat->new(time()); + $args{value}->bmul(1000); +- $args{value} = int($args{value}); ++ $args{value} = $args{value}->as_number('zero'); + } + } + elsif ( $n == 1 ) { +@@ -53,7 +53,7 @@ sub BUILDARGS { + if ( !$Config{use64bitint} && ref($args{value}) ne 'Math::BigInt' ) { + $args{value} = Math::BigFloat->new(shift); + $args{value}->bmul(1000); +- $args{value} = int($args{value}); ++ $args{value} = $args{value}->as_number('zero'); + } + else { + $args{value} = 1000 * shift; +@@ -73,7 +73,7 @@ sub BUILDARGS { + if ( !$Config{use64bitint} && ref($args{value}) ne 'Math::BigInt' ) { + $args{value} = Math::BigFloat->new(shift); + $args{value}->bmul(1000); +- $args{value} = int($args{value}); ++ $args{value} = $args{value}->as_number('zero'); + } + else { + $args{value} = 1000 * shift; +-- +2.7.4 + diff --git a/perl-BSON.spec b/perl-BSON.spec index 760c5d9..66d7267 100644 --- a/perl-BSON.spec +++ b/perl-BSON.spec @@ -1,11 +1,14 @@ Name: perl-BSON Version: 1.2.2 -Release: 2%{?dist} +Release: 3%{?dist} Summary: BSON serialization and deserialization License: ASL 2.0 Group: Development/Libraries URL: http://search.cpan.org/dist/BSON/ Source0: http://www.cpan.org/authors/id/M/MO/MONGODB/BSON-v%{version}.tar.gz +# Fix constructing BSON::Time objects on 32-bit perl, bug #1401448, +# +Patch0: BSON-v1.2.2-Do-not-produce-Math-BigFloat-by-BSON-Time.patch BuildArch: noarch BuildRequires: findutils BuildRequires: make @@ -83,6 +86,7 @@ versa in accordance with the BSON specification . %prep %setup -q -n BSON-v%{version} +%patch0 -p1 %build perl Makefile.PL INSTALLDIRS=vendor @@ -104,6 +108,9 @@ make test %{_mandir}/man3/* %changelog +* Fri Feb 24 2017 Petr Pisar - 1.2.2-3 +- Fix constructing BSON::Time objects on 32-bit perl (bug #1401448) + * Sat Feb 11 2017 Fedora Release Engineering - 1.2.2-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild