Message-ID: <39A93611.B7083CFF@softhome.net> Date: Sun, 27 Aug 2000 17:38:57 +0200 From: Laurynas Biveinis X-Mailer: Mozilla 4.74 [en] (Win98; U) X-Accept-Language: lt,en MIME-Version: 1.0 To: DJGPP Workers Subject: Patch: symlinks in mktemp() Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Tested, works. Any comments? Laurynas Index: mktemp.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/compat/stdio/mktemp.c,v retrieving revision 1.1 diff -u -r1.1 mktemp.c --- mktemp.c 1996/01/24 03:30:18 1.1 +++ mktemp.c 2000/08/27 15:35:03 @@ -1,7 +1,9 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include +#include #include #include #include @@ -14,6 +16,7 @@ static int count = 0; char *cp, *dp; int i, len, xcount, loopcnt; + char real_path[FILENAME_MAX]; /* Reinitialize counter if we were restarted (emacs). */ if (__bss_count != mktemp_count) @@ -58,7 +61,12 @@ int c = count++; for (i = 0; i < xcount; i++, c >>= 5) cp[i] = "abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f]; - if (!__file_exists(_template)) + if (!__solve_symlinks(_template, real_path)) + { + *_template = 0; + return 0; + } + if (!__file_exists(real_path)) return _template; } }