<pre style='margin:0'>
Kurt Hindenburg (kurthindenburg) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/815f44ed8b2ae2a375dcb324aff49d49cf8009fa">https://github.com/macports/macports-ports/commit/815f44ed8b2ae2a375dcb324aff49d49cf8009fa</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 815f44ed8b2ae2a375dcb324aff49d49cf8009fa
</span>Author: Kurt Hindenburg <kurt.hindenburg@gmail.com>
AuthorDate: Thu May 23 09:51:05 2019 -0400
<span style='display:block; white-space:pre;color:#404040;'> pstotext: add patch file
</span>---
textproc/pstotext/files/patch-security-popen.diff | 141 ++++++++++++++++++++++
1 file changed, 141 insertions(+)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/textproc/pstotext/files/patch-security-popen.diff b/textproc/pstotext/files/patch-security-popen.diff
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..b48d220
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/textproc/pstotext/files/patch-security-popen.diff
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,141 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Subject: Security fix, arbitratry code execution via bad popen(3) call
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Bug-Debian: http://bugs.debian.org/356988
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Author: J.H.M. Dassen (Ray) <jdassen@debian.org>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Author: Martin Ehmsen <ehmsen@gentoo.org>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+Last-Update: 2010-07-10
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- main.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ main.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -126,12 +126,14 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ static int cleanup(void) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int gsstatus, status = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ pstotextExit(instance);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (gs!=NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #ifdef VMS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (gs!=NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ gsstatus = fclose(gs);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- gsstatus = pclose(gs);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ waitpid(-1, &gsstatus, 0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (gsstatus) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (WIFEXITED(gsstatus)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (WEXITSTATUS(gsstatus)!=0) status = 3;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ else if (WIFSIGNALED(gsstatus)) status = 4;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -166,8 +168,13 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ static int do_it(char *path) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* If "path" is NULL, then "stdin" should be processed. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char *gs_cmdline;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- char *input;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char *gs_argv[32];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int gs_argc=0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef DEBUG
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int i;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int fd[2];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pid_t p;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int status;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char norotate[] = "";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ FILE *fileout;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -201,47 +208,31 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (path==NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- input = (char*)malloc(2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (input == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf(stderr,"No memory available\n");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- cleanup();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strcpy(input, "-");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- input = (char*)malloc(strlen(path) + 6);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (input == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf(stderr,"No memory available\n");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- cleanup();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strcpy(input, "-- '"); strcat(input, path); strcat(input, "'");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "gs";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "-r72";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "-dNODISPLAY";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "-dFIXEDMEDIA";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "-dDELAYBIND";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "-dWRITESYSTEMDICT";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!debug) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "-q";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "-dNOPAUSE";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "-dSAFER";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (rotate_path && strcmp(rotate_path, "")) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = rotate_path;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (ocr_path && strcmp(ocr_path, "")) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = ocr_path;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (path == NULL ) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "-";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = "--";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = path;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- gs_cmdline = (char*)malloc(strlen(gs_cmd)+strlen(rotate_path)+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- strlen(ocr_path) + strlen(input) + 128);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (gs_cmdline == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- fprintf(stderr, "No memory available\n");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- cleanup();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- sprintf(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- gs_cmdline,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#ifdef VMS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- "%s -r72 \"-dNODISPLAY\" \"-dFIXEDMEDIA\" \"-dDELAYBIND\" \"-dWRITESYSTEMDICT\" %s \"-dNOPAUSE\" %s %s %s",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- "%s -r72 -dNODISPLAY -dFIXEDMEDIA -dDELAYBIND -dWRITESYSTEMDICT %s -dNOPAUSE %s %s %s",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+-#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- gs_cmd,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- (debug ? "" : "-q"),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- rotate_path,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ocr_path,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- input
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (debug) fprintf(stderr, "%s\n", gs_cmdline);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs_argv[gs_argc++] = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #ifdef VMS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cmdfile = tempnam("SYS$SCRATCH:","PS2TGS");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ gsoutfile = tempnam("SYS$SCRATCH:","GSRES");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -259,8 +250,25 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- gs = popen(gs_cmdline, "r");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (gs==0) {perror(cmd); exit(1);}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (pipe(fd)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ perror("pipe failed: "); exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ p = fork();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (p == -1) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ perror("fork failed: "); exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (p == 0) { /* child */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ close(fd[0]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ dup2(fd[1], 1); /* Redirect stdout into pipe to parent */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ execvp("@PREFIX@/bin/gs", gs_argv);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ perror("execvp: "); status=cleanup(); exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ } else { /* parent */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ close(fd[1]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ gs = fdopen(fd[0], "r");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (gs == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ perror("fdopen: "); status=cleanup(); exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ status = pstotextInit(&instance);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (status!=0) {
</span></pre><pre style='margin:0'>
</pre>