Fix double-to-string conversion on e.g. ppc64 (bug #1014772).

Resolves: rhbz#1014772
This commit is contained in:
Tim Waugh 2014-08-15 10:13:03 +01:00
parent feb0824213
commit 739f5614e6
2 changed files with 33 additions and 1 deletions

25
ghostscript-trio-g.patch Normal file
View File

@ -0,0 +1,25 @@
diff -up ghostscript-9.14/trio/trio.c.trio-g ghostscript-9.14/trio/trio.c
--- ghostscript-9.14/trio/trio.c.trio-g 2014-03-26 12:53:48.000000000 +0000
+++ ghostscript-9.14/trio/trio.c 2014-08-15 10:10:39.714065073 +0100
@@ -3172,6 +3172,9 @@ TRIO_ARGS6((self, number, flags, width,
if (integerNumber > epsilon)
{
integerDigits += (int)TrioLogarithm(integerNumber, base);
+ /* Deal with the dangers of casting long double to int */
+ if (integerNumber - TrioPower (base, integerDigits) >= 0)
+ integerDigits++;
}
fractionDigits = precision;
@@ -3255,6 +3258,11 @@ TRIO_ARGS6((self, number, flags, width,
integerDigits = (integerNumber > epsilon)
? 1 + (int)TrioLogarithm(integerNumber, base)
: 1;
+
+ /* Deal with the dangers of casting long double to int */
+ if (integerNumber - TrioPower (base, integerDigits) >= 0)
+ integerDigits++;
+
if (flags & FLAGS_FLOAT_G)
{
if (flags & FLAGS_ALTERNATIVE)

View File

@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer
Name: ghostscript
Version: %{gs_ver}
Release: 3%{?dist}
Release: 4%{?dist}
# Included CMap data is Redistributable, no modification permitted,
# see http://bugzilla.redhat.com/487510
@ -33,6 +33,7 @@ Patch9: ghostscript-wrf-snprintf.patch
Patch10: ghostscript-gs694154.patch
Patch11: ghostscript-sys-zlib.patch
Patch12: ghostscript-crash.patch
Patch13: ghostscript-trio-g.patch
Requires: urw-fonts >= 1.1, ghostscript-fonts
Requires: poppler-data
@ -142,6 +143,9 @@ rm -rf expat freetype icclib jasper jpeg jpegxr lcms lcms2 libpng openjpeg zlib
# Prevent memory handling crash.
%patch12 -p1 -b .crash
# Fix double-to-string conversion on e.g. ppc64 (bug #1014772).
%patch13 -p1 -b .trio-g
# Convert manual pages to UTF-8
from8859_1() {
iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_"
@ -333,6 +337,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/libgs.so
%changelog
* Fri Aug 15 2014 Tim Waugh <twaugh@redhat.com> 9.14-4
- Fix double-to-string conversion on e.g. ppc64 (bug #1014772).
* Wed Jun 4 2014 Tim Waugh <twaugh@redhat.com> 9.14-3
- Applied patch from upstream to fix memory handling issue that could
lead to crashes (bug #1087071).