diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-08-11 16:43:26 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-08-11 16:43:26 +0000 |
commit | 6e2c582323d667fec9b1859757515f932c6f8db2 (patch) | |
tree | 4ac291c9d61de0592dd49636f0dc9272bd9e9a89 /winsup/cygwin | |
parent | 3b7cd74bfdf5632be8d4af1fe28c774f96f1a4fd (diff) | |
download | cygnal-6e2c582323d667fec9b1859757515f932c6f8db2.tar.gz cygnal-6e2c582323d667fec9b1859757515f932c6f8db2.tar.bz2 cygnal-6e2c582323d667fec9b1859757515f932c6f8db2.zip |
* fhandler_proc.cc (fhandler_proc::get_proc_fhandler): Don't allow to
access process info by using the Windows PID.
* fhandler_process.cc (fhandler_process::fstat): Ditto.
(fhandler_process::fill_filebuf): Ditto.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_proc.cc | 8 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_process.cc | 14 |
3 files changed, 25 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 04c80fe9a..8dc5248db 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,12 @@ 2011-08-11 Corinna Vinschen <corinna@vinschen.de> + * fhandler_proc.cc (fhandler_proc::get_proc_fhandler): Don't allow to + access process info by using the Windows PID. + * fhandler_process.cc (fhandler_process::fstat): Ditto. + (fhandler_process::fill_filebuf): Ditto. + +2011-08-11 Corinna Vinschen <corinna@vinschen.de> + * (winpids::add): Make sure to store always a Windows PID in pidlist, even if pid is a Cygwin PID. (winpids::enum_processes): Fetch Cygwin processes from listing of diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 9310696bc..63178a003 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -128,7 +128,13 @@ fhandler_proc::get_proc_fhandler (const char *path) if (entry) return entry->fhandler; - if (pinfo (atoi (path))) + int pid = atoi (path); + pinfo p (pid); + /* If p->pid != pid, then pid is actually the Windows PID for an execed + Cygwin process, and the pinfo entry is the additional entry created + at exec time. We don't want to enable the user to access a process + entry by using the Win32 PID, though. */ + if (p && p->pid == pid) return FH_PROCESS; bool has_subdir = false; diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index 09ca2c77c..eb36d9d56 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -143,8 +143,13 @@ fhandler_process::fstat (struct __stat64 *buf) fhandler_base::fstat (buf); path += proc_len + 1; pid = atoi (path); + pinfo p (pid); - if (!p) + /* If p->pid != pid, then pid is actually the Windows PID for an execed + Cygwin process, and the pinfo entry is the additional entry created + at exec time. We don't want to enable the user to access a process + entry by using the Win32 PID, though. */ + if (!p || p->pid != pid) { set_errno (ENOENT); return -1; @@ -320,8 +325,11 @@ fhandler_process::fill_filebuf () pid = atoi (path); pinfo p (pid); - - if (!p) + /* If p->pid != pid, then pid is actually the Windows PID for an execed + Cygwin process, and the pinfo entry is the additional entry created + at exec time. We don't want to enable the user to access a process + entry by using the Win32 PID, though. */ + if (!p || p->pid != pid) { set_errno (ENOENT); return false; |