1 --- a2ps-4.13/lib/routines.c~ 1999-10-16 06:46:37.000000000 +0200
2 +++ a2ps-4.13/lib/routines.c 2003-08-21 09:58:57.361425544 +0200
4 /* Don't complain if you can't unlink. Who cares of a tmp file? */
9 + * Securely generate a temp file, and make sure it gets
10 + * deleted upon exit.
12 +static char ** tempfiles = NULL;
13 +static unsigned ntempfiles = 0;
18 + while (ntempfiles--)
19 + unlink(tempfiles[ntempfiles]);
23 +safe_tempnam(const char *pfx)
25 + char *dirname, *filename;
28 + if (!(dirname = getenv("TMPDIR")))
31 + tempfiles = (char **) realloc(tempfiles,
32 + (ntempfiles+1) * sizeof(char *));
33 + if (tempfiles == NULL)
36 + filename = malloc(strlen(dirname) + strlen(pfx) + sizeof("/XXXXXX"));
40 + sprintf(filename, "%s/%sXXXXXX", dirname, pfx);
42 + if ((fd = mkstemp(filename)) < 0) {
48 + if (ntempfiles == 0)
49 + atexit(cleanup_tempfiles);
50 + tempfiles[ntempfiles++] = filename;
54 --- a2ps-4.13/lib/routines.h~ 1999-10-18 22:24:41.000000000 +0200
55 +++ a2ps-4.13/lib/routines.h 2003-08-21 09:55:11.500761584 +0200
57 /* If _STR_ is not defined, give it a tempname in _TMPDIR_ */
58 #define tempname_ensure(Str) \
60 - (Str) = (Str) ? (Str) : tempnam (NULL, "a2_"); \
61 + (Str) = (Str) ? (Str) : safe_tempnam("a2_"); \
64 +char * safe_tempnam(const char *);