freebsd-ports/print/ghostscript7-base/files/patch-src-ibnum.c
Hiroki Sato 27470e1676 - Split ghostscript into X11-independent and -dependent parts:
* print/ghostscript{7,8,9,9-agpl}-base

   Installs Ghostscript binary, libgs, and related files.
   These ports do not depend on X11 libraries (i.e. x11* devices
   are not available).  USES=ghostscript will set dependency on
   one of them depending on GHOSTSCRIPT_DEFAULT.

   The default device is set to "display" or "bbox".

 * print/ghostscript{7,8,9,9-agpl}-x11

   Installs a shared library which provides X11 support to
   the installed Ghostscript binaries.  x11* devices will be
   enabled when the library is available.

   This depends on *-base (RUN_DEPENDS).  USES=ghostscript:x11
   will set dependency on one of them.

- Fix integer overflow reported as CVE-2015-3228.

- Update Uses/ghostscript.mk:

 * Add x11 keyword.  nox11 keyword is now obsolete.

 * Use packagename in *_DEPENDS line to prevent relationship between
   -base and -x11 packages from being broken.

- Fix x11/nox11 keyword and bump PORTREVISION in ports using
  USES=ghostscript to update dependency of pre-compiled packages.
2015-08-22 17:48:35 +00:00

49 lines
1.3 KiB
C

--- src/ibnum.c.orig 2003-01-17 09:49:04.000000000 +0900
+++ src/ibnum.c 2013-04-30 11:18:27.000000000 +0900
@@ -124,11 +124,11 @@
case num_int32:
case num_int32 + 16:
if ((format & 31) == 0) {
- np->value.intval = sdecodelong(str, format);
+ np->value.intval = sdecodeint32(str, format);
return t_integer;
} else {
np->value.realval =
- (double)sdecodelong(str, format) *
+ (double)sdecodeint32(str, format) *
binary_scale[format & 31];
return t_real;
}
@@ -171,18 +171,14 @@
}
/* Decode a (32-bit, signed) long. */
-long
-sdecodelong(const byte * p, int format)
+int
+sdecodeint32(const byte * p, int format)
{
int a = p[0], b = p[1], c = p[2], d = p[3];
- long v = (num_is_lsb(format) ?
- ((long)d << 24) + ((long)c << 16) + (b << 8) + a :
- ((long)a << 24) + ((long)b << 16) + (c << 8) + d);
+ int v = (num_is_lsb(format) ?
+ ((int)d << 24) + ((int)c << 16) + (b << 8) + a :
+ ((int)a << 24) + ((int)b << 16) + (c << 8) + d);
-#if arch_sizeof_long > 4
- /* Propagate bit 31 as the sign. */
- v = (v ^ 0x80000000L) - 0x80000000L;
-#endif
return v;
}
@@ -190,7 +186,7 @@
float
sdecodefloat(const byte * p, int format)
{
- bits32 lnum = (bits32) sdecodelong(p, format);
+ bits32 lnum = (bits32) sdecodeint32(p, format);
float fnum;
#if !arch_floats_are_IEEE