--- scrollkeeper/extract/dtds/Makefile.in.old Wed May 1 15:55:59 2002 +++ scrollkeeper/extract/dtds/Makefile.in Wed May 1 15:56:07 2002 @@ -222,7 +222,6 @@ install-data-am: install-dtdsHEADERS @$(NORMAL_INSTALL) - $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-data: install-data-am install-am: all-am diff -u -Nur --exclude CVS orig/scrollkeeper-0.3.6/libs/extract.c scrollkeeper-0.3.6/libs/extract.c --- scrollkeeper-0.3.6/libs/extract.c 2002-03-21 06:08:51.000000000 +0100 +++ scrollkeeper-0.3.6/libs/extract.c 2002-09-02 21:33:16.000000000 +0200 @@ -49,8 +49,8 @@ FILE *res_fid; char *doctype; char command[1024]; - pid_t pid; char temp1[PATHLEN], temp2[PATHLEN], errors[PATHLEN]; + int temp1_fd, temp2_fd, errors_fd; #endif struct stat buf; @@ -69,11 +69,22 @@ #ifdef SOLARIS doc = docbParseFile(input_file, NULL); #else - pid = getpid(); - - snprintf(temp1, PATHLEN, "/var/tmp/scrollkeeper-extract-1-%ld.xml", (long)pid); - snprintf(temp2, PATHLEN, "/var/tmp/scrollkeeper-extract-2-%ld.xml", (long)pid); - snprintf(errors, PATHLEN, "/var/tmp/scrollkeeper-extract-errors-%ld", (long)pid); + snprintf(temp1, PATHLEN, "/var/tmp/scrollkeeper-extract-1.xml.XXXXXX"); + snprintf(temp2, PATHLEN, "/var/tmp/scrollkeeper-extract-2.xml.XXXXXX"); + snprintf(errors, PATHLEN, "/var/tmp/scrollkeeper-extract-errors.XXXXXX"); + + temp1_fd = mkstemp(temp1); + if (temp1_fd == -1) { + sk_message(outputprefs, SKOUT_DEFAULT, SKOUT_QUIET, "(apply_stylesheets)", _("Cannot open temporary file: %s : %s\n"), temp1, strerror(errno)); + return 0; + } + + errors_fd = mkstemp(errors); + if (errors_fd == -1) { + sk_message(outputprefs, SKOUT_DEFAULT, SKOUT_QUIET, "(apply_stylesheets)", _("Cannot open temporary file: %s : %s\n"), errors, strerror(errno)); + return 0; + } + close(errors_fd); snprintf(command, 1024, "sgml2xml -xlower -f%s %s > %s", errors, input_file, temp1); system(command); @@ -83,6 +94,7 @@ fid = fopen(input_file, "r"); if (fid == NULL) { sk_message(outputprefs, SKOUT_DEFAULT, SKOUT_QUIET, "(apply_stylesheets)", _("Cannot read file: %s : %s\n"),input_file, strerror(errno)); + close(temp1_fd); return 0; } @@ -106,14 +118,26 @@ } if (doctype == NULL) { + close(temp1_fd); unlink(temp1); return 0; } - fid = fopen(temp1, "r"); - res_fid = fopen(temp2, "w"); + temp2_fd = mkstemp(temp2); + if (temp2_fd == -1) { + close(temp1_fd); + unlink(temp1); + sk_message(outputprefs, SKOUT_DEFAULT, SKOUT_QUIET, "(apply_stylesheets)", _("Cannot create temporary file: %s : %s\n"),temp2, strerror(errno)); + return 0; + } + + fid = fdopen(temp1_fd, "r"); + res_fid = fdopen(temp2_fd, "w"); + if (fid == NULL || res_fid == NULL) { + close(temp1_fd); unlink(temp1); + close(temp2_fd); unlink(temp2); return 0; } --- scrollkeeper-0.3.6/cl/src/get-cl.c 2002-03-21 06:08:51.000000000 +0100 +++ scrollkeeper-0.3.6/cl/src/get-cl.c 2002-09-02 21:31:43.000000000 +0200 @@ -27,6 +27,7 @@ #include #include #include +#include /* cycles through five temporary filenames of the form /tmp/scrollkeeper-templfile.x, where x is number from 0 to 4 and returns the first one that does not exist or the @@ -36,6 +37,7 @@ { char path[PATHLEN], *filename; int i, num; + int fd; struct stat buf; time_t prev; @@ -82,6 +84,17 @@ check_ptr(filename, "scrollkeeper-get-cl"); snprintf(filename, PATHLEN, "/tmp/scrollkeeper-tempfile.%d", num); + unlink(filename); + + fd = open(filename, O_RDWR | O_CREAT | O_EXCL | O_TRUNC | O_NONBLOCK, + S_IRWXU | S_IRGRP | S_IROTH); + + if (fd < 0) { + fprintf (stderr, _("scrollkeeper-get-cl: Cannot open temporary file: %s\n"), filename); + exit (EXIT_FAILURE); + } + close(fd); + return filename; }