delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/08/28/09:43:47

Message-ID: <39AA6D73.40E10BF2@softhome.net>
Date: Mon, 28 Aug 2000 15:47:31 +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 mkstemp()
Reply-To: djgpp-workers AT delorie DOT com

This is the last missing piece in symlink puzzle, as pointed
out by Eli. I'll submit yet another one patch which makes 
open() to resolve leading dirs even with O_NOLINK flag, but
is there anything else skipped?

Tested, works[*].

Any comments?

Laurynas

[*] For me.

Index: mkstemp.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/stdio/mkstemp.c,v
retrieving revision 1.2
diff -u -p -r1.2 mkstemp.c
--- mkstemp.c	1998/12/13 13:10:58	1.2
+++ mkstemp.c	2000/08/28 13:41:17
@@ -1,5 +1,7 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#include <libc/symlink.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -9,6 +11,7 @@ int
 mkstemp (char *_template)
 {
   char tmp_name[FILENAME_MAX];
+  char real_path[FILENAME_MAX];
   int  fd = -1;
 
   /* Make sure we create a non-exisiting file, even
@@ -17,7 +20,8 @@ mkstemp (char *_template)
     strcpy(tmp_name, _template);
     errno = 0;
   } while (mktemp (tmp_name) != NULL
-	   && (fd = _creatnew(tmp_name, 0, SH_DENYRW)) == -1
+           && __solve_symlinks(tmp_name, real_path)
+	   && (fd = _creatnew(real_path, 0, SH_DENYRW)) == -1
 	   && errno == EEXIST);
 
   if (fd == -1)

- Raw text -


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