delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/08/27/11:36:45

Message-ID: <39A93611.B7083CFF@softhome.net>
Date: Sun, 27 Aug 2000 17:38:57 +0200
From: Laurynas Biveinis <lauras AT softhome DOT net>
X-Mailer: Mozilla 4.74 [en] (Win98; U)
X-Accept-Language: lt,en
MIME-Version: 1.0
To: DJGPP Workers <djgpp-workers AT delorie DOT com>
Subject: Patch: symlinks in mktemp()
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 <libc/stubs.h>
 #include <libc/bss.h>
+#include <libc/symlink.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
@@ -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;
     }
   }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019