about summary refs log tree commit diff
path: root/sysdeps/posix/getaddrinfo.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-09-29 02:56:42 +0000
committerUlrich Drepper <drepper@redhat.com>2000-09-29 02:56:42 +0000
commite658b54e8e67c00063a0b549fa25b73d8e6d4076 (patch)
tree2c481b771c920873bdf6977faf071eafda5c39c5 /sysdeps/posix/getaddrinfo.c
parentee6c5330273edda1ab102ad780d1984aca055e77 (diff)
downloadglibc-e658b54e8e67c00063a0b549fa25b73d8e6d4076.tar.gz
glibc-e658b54e8e67c00063a0b549fa25b73d8e6d4076.tar.xz
glibc-e658b54e8e67c00063a0b549fa25b73d8e6d4076.zip
Update.
	* stdio-common/tmpnam.c (tmpnam): Optimize a bit.

	* sysdeps/posix/getaddrinfo.c (gaih_local): Don't use tmpnam, use
	underlying functions directly.
Diffstat (limited to 'sysdeps/posix/getaddrinfo.c')
-rw-r--r--sysdeps/posix/getaddrinfo.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index fdd8729657..7a84cd3030 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -206,7 +206,15 @@ gaih_local (const char *name, const struct gaih_service *service,
     }
   else
     {
-      if (tmpnam (((struct sockaddr_un *) (*pai)->ai_addr)->sun_path) == NULL)
+      /* This is a dangerous use of the interface since there is a time
+	 window between the test for the file and the actual creation
+	 (done by the caller) in which a file with the same name could
+	 be created.  */
+      char *buf = ((struct sockaddr_un *) (*pai)->ai_addr)->sun_path;
+
+      if (__builtin_expect (__path_search (buf, L_tmpnam, NULL, NULL, 0),
+			    0) != 0
+	  || __builtin_expect (__gen_tempname (buf, __GT_NOCREATE), 0) != 0)
 	return -EAI_SYSTEM;
     }