* Makefile.in (DLL_OFILES): Add tls_pbuf.o.

* autoload.cc (CreateDesktopW): Replace CreateDesktopA.
	(CreateWindowStationW): Replace CreateWindowStationA.
	(GetUserObjectInformationW): Replace GetUserObjectInformationA.
	* cygheap.h (cwdstuff::get): Assume default buffer size NT_MAX_PATH.
	* cygtls.cc (_cygtls::remove): Free temporary TLS path buffers.
	* cygtls.h (TP_NUM_C_BUFS): Define.
	(TP_NUM_W_BUFS): Define.
	(class tls_pathbuf): New class to store pointers to thread local
	temporary path buffers.
	(_local_storage::pathbufs): New member.
	* environ.cc (win_env::add_cache): Use temporary TLS path buffer instead
	of stack based buffer.
	(posify): Get temporary outenv buffer from calling function.
	(environ_init): Create temporary TLS path buffer for posify.
	(build_env): Create Windows environment block as WCHAR buffer.
	* environ.h (build_env): Change declaration accordingly.
	* external.cc (sync_winenv): Accommodate build_env change.
	* fhandler_console.cc (fhandler_console::need_invisible): Use
	GetUserObjectInformationW and CreateWindowStationW.
	* fhandler_process.cc (format_process_maps): Use temporary TLS path
	buffer instead of stack based buffer.
	* fork.cc (frok::parent): Convert to use CreateProcessW.
	* path.cc: Throughout use temporary TLS path buffers instead of stack
	based buffer.  Replace checks for CYG_MAX_PATH by checks for
	NT_MAX_PATH.
	(getfileattr): New function to replace GetFileAttributesA.
	(normalize_win32_path): Remove Win32 and NT long path prefixes.
	(getwd): Assume PATH_MAX + 1 buffer per SUSv3.
	* path.h (class path_conv): Set path buffer to size NT_MAX_PATH.
	(iswdrive): Define.
	* pinfo.cc (commune_process): Use temporary TLS path buffer instead of
	stack based buffer.
	* registry.cc (get_registry_hive_path): Ditto.
	(load_registry_hive): Ditto.
	* spawn.cc (spawn_guts): Convert to use CreateProcessW and
	CreateProcessAsUserW.
	(av::fixup): Open/close file using NtOpenFile/NtClose.
	* syscalls.cc (mknod_worker): Allow PATH_MAX file name.
	(mknod32): Ditto.
	(getusershell): Ditto.
	* tls_pbuf.cc: New file implementing tls_pathbuf and tmp_pathbuf
	methods.
	* tls_pbuf.h: New header for files using tmp_pathbuf.
	* tlsoffsets.h: Regenerate.
	* winsup.h (NT_MAX_PATH): Define as 32767 to avoid USHORT overflow.
This commit is contained in:
Corinna Vinschen
2008-03-07 11:24:51 +00:00
parent d8e218442b
commit 752b16ce35
22 changed files with 467 additions and 203 deletions

View File

@@ -2336,7 +2336,7 @@ static int __stdcall
mknod_worker (const char *path, mode_t type, mode_t mode, _major_t major,
_minor_t minor)
{
char buf[sizeof (":\\00000000:00000000:00000000") + CYG_MAX_PATH];
char buf[sizeof (":\\00000000:00000000:00000000") + PATH_MAX];
sprintf (buf, ":\\%x:%x:%x", major, minor,
type | (mode & (S_IRWXU | S_IRWXG | S_IRWXO)));
return symlink_worker (buf, path, true, true);
@@ -2354,7 +2354,7 @@ mknod32 (const char *path, mode_t mode, __dev32_t dev)
return -1;
}
if (strlen (path) >= CYG_MAX_PATH)
if (strlen (path) >= PATH_MAX)
return -1;
path_conv w32path (path, PC_SYM_NOFOLLOW);
@@ -3327,7 +3327,7 @@ getusershell ()
"/usr/bin/csh",
NULL
};
static char buf[CYG_MAX_PATH];
static char buf[PATH_MAX];
int ch, buf_idx;
if (!shell_fp && !(shell_fp = fopen64 (ETC_SHELLS, "rt")))
@@ -3342,11 +3342,11 @@ getusershell ()
/* Get each non-whitespace character as part of the shell path as long as
it fits in buf. */
for (buf_idx = 0;
ch != EOF && !isspace (ch) && buf_idx < CYG_MAX_PATH;
ch != EOF && !isspace (ch) && buf_idx < PATH_MAX;
buf_idx++, ch = getc (shell_fp))
buf[buf_idx] = ch;
/* Skip any trailing non-whitespace character not fitting in buf. If the
path is longer than CYG_MAX_PATH, it's invalid anyway. */
path is longer than PATH_MAX, it's invalid anyway. */
while (ch != EOF && !isspace (ch))
ch = getc (shell_fp);
if (buf_idx)