From 9b735b55ad2d731f011b8705dc5471b8982d5cc6 Mon Sep 17 00:00:00 2001 From: corinna Date: Wed, 21 May 2003 08:01:55 +0000 Subject: [PATCH] * shared_info.h: Match shared_name declaration with below change. * shared.cc (shared_name): Use incoming char * parameter instead of local static buffer. (open_shared): Accomodate new calling convention for shared_name. * exceptions.cc (events_init): Ditto. * sigproc.cc (getsem): Ditto. * syscalls.cc (login): Ditto. (logout): Ditto. (pututline): Ditto. --- winsup/cygwin/ChangeLog | 14 +++++++++++++- winsup/cygwin/exceptions.cc | 4 +++- winsup/cygwin/shared.cc | 12 ++++++------ winsup/cygwin/shared_info.h | 2 +- winsup/cygwin/sigproc.cc | 5 +++-- winsup/cygwin/syscalls.cc | 12 +++++++++--- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 56941e73aa..593508564c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,7 +1,19 @@ +2003-05-21 Corinna Vinschen + + * shared_info.h: Match shared_name declaration with below change. + * shared.cc (shared_name): Use incoming char * parameter instead of + local static buffer. + (open_shared): Accomodate new calling convention for shared_name. + * exceptions.cc (events_init): Ditto. + * sigproc.cc (getsem): Ditto. + * syscalls.cc (login): Ditto. + (logout): Ditto. + (pututline): Ditto. + 2003-05-20 Corinna Vinschen * fhandler_socket.cc (secret_event_name): Return void. Use incoming - char *parameter instead of local static buffer. + char * parameter instead of local static buffer. (fhandler_socket::create_secret_event): Accomodate new calling convention for secret_event_name. (fhandler_socket::close_secret_event): Ditto. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index ec4b7f4c9a..482745e89b 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1134,11 +1134,13 @@ void events_init (void) { char *name; + char mutex_name[MAX_PATH]; /* title_mutex protects modification of console title. It's necessary while finding console window handle */ if (!(title_mutex = CreateMutex (&sec_all_nih, FALSE, - name = shared_name ("title_mutex", 0)))) + name = shared_name (mutex_name, + "title_mutex", 0)))) api_fatal ("can't create title mutex '%s', %E", name); ProtectHandle (title_mutex); diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index 2a6ae9087c..c8c764c74c 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -33,17 +33,16 @@ mount_info NO_COPY *mount_table; HANDLE NO_COPY cygwin_mount_h; char * __stdcall -shared_name (const char *str, int num) +shared_name (char *ret_buf, const char *str, int num) { - static NO_COPY char buf[MAX_PATH] = {0}; extern bool _cygwin_testing; - __small_sprintf (buf, "%s%s.%s.%d", + __small_sprintf (ret_buf, "%s%s.%s.%d", wincap.has_terminal_services () ? "Global\\" : "", cygwin_version.shared_id, str, num); if (_cygwin_testing) - strcat (buf, cygwin_version.dll_build_date); - return buf; + strcat (ret_buf, cygwin_version.dll_build_date); + return ret_buf; } #define page_const (65535) @@ -88,11 +87,12 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locat if (!shared_h) { char *mapname; + char map_buf[MAX_PATH]; if (!name) mapname = NULL; else { - mapname = shared_name (name, n); + mapname = shared_name (map_buf, name, n); shared_h = OpenFileMappingA (FILE_MAP_READ | FILE_MAP_WRITE, TRUE, mapname); } diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h index 0156763e6a..c9cf6a359f 100644 --- a/winsup/cygwin/shared_info.h +++ b/winsup/cygwin/shared_info.h @@ -186,5 +186,5 @@ struct console_state }; #endif -char *__stdcall shared_name (const char *, int); +char *__stdcall shared_name (char *, const char *, int); void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locations); diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 124b8d059a..5d3b2e2205 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -883,6 +883,7 @@ static HANDLE __stdcall getsem (_pinfo *p, const char *str, int init, int max) { HANDLE h; + char sem_name[MAX_PATH]; if (p != NULL) { @@ -906,7 +907,7 @@ getsem (_pinfo *p, const char *str, int init, int max) DWORD winpid = GetCurrentProcessId (); h = CreateSemaphore (sec_user_nih (sa_buf), init, max, - str = shared_name (str, winpid)); + str = shared_name (sem_name, str, winpid)); p = myself; if (!h) { @@ -917,7 +918,7 @@ getsem (_pinfo *p, const char *str, int init, int max) else { h = OpenSemaphore (SEMAPHORE_ALL_ACCESS, FALSE, - shared_name (str, p->dwProcessId)); + shared_name (sem_name, str, p->dwProcessId)); if (!h) { diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index f66363f7dd..625e059570 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -2540,7 +2540,9 @@ login (struct utmp *ut) pututline (ut); endutent (); /* Writing to wtmp must be atomic to prevent mixed up data. */ - HANDLE mutex = CreateMutex (NULL, FALSE, shared_name ("wtmp_mutex", 0)); + char mutex_name[MAX_PATH]; + HANDLE mutex = CreateMutex (NULL, FALSE, + shared_name (mutex_name, "wtmp_mutex", 0)); if (mutex) while (WaitForSingleObject (mutex, INFINITE) == WAIT_ABANDONED) ; @@ -2578,7 +2580,9 @@ logout (char *line) memset (ut_buf.ut_user, 0, sizeof ut_buf.ut_user); time (&ut_buf.ut_time); /* Writing to wtmp must be atomic to prevent mixed up data. */ - HANDLE mutex = CreateMutex (NULL, FALSE, shared_name ("wtmp_mutex", 0)); + char mutex_name[MAX_PATH]; + HANDLE mutex = CreateMutex (NULL, FALSE, + shared_name (mutex_name, "wtmp_mutex", 0)); if (mutex) while (WaitForSingleObject (mutex, INFINITE) == WAIT_ABANDONED) ; @@ -2747,7 +2751,9 @@ pututline (struct utmp *ut) return; /* Read/write to utmp must be atomic to prevent overriding data by concurrent processes. */ - HANDLE mutex = CreateMutex (NULL, FALSE, shared_name ("utmp_mutex", 0)); + char mutex_name[MAX_PATH]; + HANDLE mutex = CreateMutex (NULL, FALSE, + shared_name (mutex_name, "utmp_mutex", 0)); if (mutex) while (WaitForSingleObject (mutex, INFINITE) == WAIT_ABANDONED) ; -- 2.11.0