1 Updated By: Bruce Dubbs (bdubbs -aT- linuxfromscratch -DoT- org)
3 Submitted By: Archaic (archaic -aT- linuxfromscratch -DoT- org)
5 Initial Package Version: 4.8
6 Origin: http://gentoo.kems.net/gentoo-portage/sys-apps/texinfo/files/texinfo-4.8-tempfile.patch
7 Upstream Status: A few patches are floating around in Debian BZ #328365 of which
8 upstream hasn't made a full commitment on yet.
9 Description: (CAN-2005-3011) texindex in texinfo 4.8 and earlier allows local
10 users to overwrite arbitrary files via a symlink attack on
12 Update: Changed to not pass a constant string to mktemp().
14 diff -Naur texinfo-4.8.orig/util/texindex.c texinfo-4.8/util/texindex.c
15 --- texinfo-4.8.orig/util/texindex.c 2005-12-11 23:29:08.000000000 -0600
16 +++ texinfo-4.8/util/texindex.c 2005-12-11 23:33:31.000000000 -0600
18 /* Directory to use for temporary files. On Unix, it ends with a slash. */
21 +/* Basename for temp files inside of tempdir. */
24 /* Number of last temporary file. */
28 main (int argc, char **argv)
31 + char template[]="txidxXXXXXX";
34 last_deleted_tempcount = 0;
37 decode_command (argc, argv);
39 + /* XXX mkstemp not appropriate, as we need to have somewhat predictable
40 + * names. But race condition was fixed, see maketempname.
42 + tempbase = mktemp (template);
44 /* Process input files completely, one by one. */
46 for (i = 0; i < num_infiles; i++)
49 maketempname (int count)
51 - static char *tempbase = NULL;
57 - tempbase = concat (tempdir, "txidxXXXXXX");
59 - fd = mkstemp (tempbase);
61 - pfatal_with_name (tempbase);
63 + char *name, *tmp_name;
66 sprintf (tempsuffix, ".%d", count);
67 - return concat (tempbase, tempsuffix);
68 + tmp_name = concat (tempdir, tempbase);
69 + name = concat (tmp_name, tempsuffix);
72 + fd = open (name, O_CREAT|O_EXCL|O_WRONLY, 0600);
74 + pfatal_with_name (name);