ports/print/ghostscript7-base/files/patch-src-gp_unix.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

80 lines
1.7 KiB
C

--- src/gp_unix.c.orig 2003-01-17 09:49:02.000000000 +0900
+++ src/gp_unix.c 2015-08-22 02:44:59.415936000 +0900
@@ -41,11 +41,57 @@
#endif
+#ifdef GS_DEVS_SHARED
+#ifndef GS_DEVS_SHARED_DIR
+# define GS_DEVS_SHARED_DIR "/usr/lib/ghostscript/7.07"
+#endif
+
+/*
+ * use shared library for drivers, always load them when starting, this
+ * avoid too many modifications, and since it is supported only under linux
+ * and applied as a patch (preferable).
+ */
+#include <sys/types.h>
+#include <limits.h>
+#include <dirent.h>
+#include <dlfcn.h>
+#include <string.h>
+
+void
+gp_init(void)
+{
+ DIR* dir = NULL;
+ struct dirent* dirent;
+ char buff[PATH_MAX];
+ char* pbuff;
+ void* handle;
+ void (*gs_shared_init)(void);
+
+ dir = opendir(GS_DEVS_SHARED_DIR);
+ if (dir == 0) return;
+
+ while ((dirent = readdir(dir)) != 0) {
+ snprintf(buff, sizeof(buff), "%s/%s", GS_DEVS_SHARED_DIR, dirent->d_name);
+ pbuff = buff + strlen(buff) - 3;
+ if (strcmp(pbuff, ".so") != 0)
+ continue;
+ handle = dlopen(buff, RTLD_NOW);
+ if (handle == NULL)
+ continue;
+ gs_shared_init = dlsym(handle, "gs_shared_init");
+ if (gs_shared_init != NULL)
+ (*gs_shared_init)();
+ }
+
+ closedir(dir);
+}
+#else
/* Do platform-dependent initialization. */
void
gp_init(void)
{
}
+#endif
/* Do platform-dependent cleanup. */
void
@@ -57,6 +103,7 @@
void
gp_do_exit(int exit_status)
{
+ exit(exit_status);
}
/* ------ Miscellaneous ------ */
@@ -67,7 +114,11 @@
const char *
gp_strerror(int errnum)
{
+#ifdef HAVE_STRERROR
+ return strerror(errnum);
+#else
return NULL;
+#endif
}
/* ------ Date and time ------ */