diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2024-04-09 16:52:58 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2024-04-09 17:02:35 +0200 |
commit | 2855c35c41ed5c950e40ce0ae0d99d00185e05ad (patch) | |
tree | 69e4670767938614d8a6721131e6b11529c22010 /winsup/cygwin/fhandler | |
parent | 38b51398359076eed01d8f1b0f9c061d16a658f5 (diff) | |
download | newlib-2855c35c41ed5c950e40ce0ae0d99d00185e05ad.zip newlib-2855c35c41ed5c950e40ce0ae0d99d00185e05ad.tar.gz newlib-2855c35c41ed5c950e40ce0ae0d99d00185e05ad.tar.bz2 |
Cygwin: fhandler_virtual::exists: always set fileid
Commit a0a25849f9dd ("Cygwin: fhandler_virtual: move fileid to path_conv
member") broke `ls -l /proc/<PID>'. Turns out, the commit forgot to set
the fileid in case of a virtual root dir (i. e., returning virt_rootdir)
in fhandlers utilizing fileid. This crashed opendir() due to a random
fileid.
Make sure to set fileid in any case.
Fixes: a0a25849f9dd ("Cygwin: fhandler_virtual: move fileid to path_conv member")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/fhandler')
-rw-r--r-- | winsup/cygwin/fhandler/proc.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/fhandler/process.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/fhandler/procnet.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/fhandler/procsysvipc.cc | 6 |
4 files changed, 20 insertions, 4 deletions
diff --git a/winsup/cygwin/fhandler/proc.cc b/winsup/cygwin/fhandler/proc.cc index 7629b54..baf0cae 100644 --- a/winsup/cygwin/fhandler/proc.cc +++ b/winsup/cygwin/fhandler/proc.cc @@ -180,7 +180,10 @@ fhandler_proc::exists () debug_printf ("exists (%s)", path); path += proc_len; if (*path == 0) - return virt_rootdir; + { + fileid () = 0; + return virt_rootdir; + } virt_tab_t *entry = virt_tab_search (path + 1, false, proc_tab, PROC_LINK_COUNT); if (entry) @@ -188,6 +191,7 @@ fhandler_proc::exists () fileid () = entry - proc_tab; return entry->type; } + fileid () = -1; return virt_none; } diff --git a/winsup/cygwin/fhandler/process.cc b/winsup/cygwin/fhandler/process.cc index 20169d2..37bdff8 100644 --- a/winsup/cygwin/fhandler/process.cc +++ b/winsup/cygwin/fhandler/process.cc @@ -95,7 +95,10 @@ fhandler_process::exists () while (*path != 0 && !isdirsep (*path)) path++; if (*path == 0) - return virt_rootdir; + { + fileid () = 0; + return virt_rootdir; + } virt_tab_t *entry = virt_tab_search (path + 1, true, process_tab, PROCESS_LINK_COUNT); @@ -122,6 +125,7 @@ fhandler_process::exists () } } } + fileid () = -1; return virt_none; } diff --git a/winsup/cygwin/fhandler/procnet.cc b/winsup/cygwin/fhandler/procnet.cc index 112aee8..631fe8c 100644 --- a/winsup/cygwin/fhandler/procnet.cc +++ b/winsup/cygwin/fhandler/procnet.cc @@ -48,7 +48,10 @@ fhandler_procnet::exists () while (*path != 0 && !isdirsep (*path)) path++; if (*path == 0) - return virt_rootdir; + { + fileid () = 0; + return virt_rootdir; + } virt_tab_t *entry = virt_tab_search (path + 1, false, procnet_tab, PROCNET_LINK_COUNT); @@ -59,6 +62,7 @@ fhandler_procnet::exists () fileid () = entry - procnet_tab; return entry->type; } + fileid () = -1; return virt_none; } diff --git a/winsup/cygwin/fhandler/procsysvipc.cc b/winsup/cygwin/fhandler/procsysvipc.cc index b322c46..dac565c 100644 --- a/winsup/cygwin/fhandler/procsysvipc.cc +++ b/winsup/cygwin/fhandler/procsysvipc.cc @@ -61,7 +61,10 @@ fhandler_procsysvipc::exists () while (*path != 0 && !isdirsep (*path)) path++; if (*path == 0) - return virt_rootdir; + { + fileid () = 0; + return virt_rootdir; + } virt_tab_t *entry = virt_tab_search (path + 1, true, procsysvipc_tab, PROCSYSVIPC_LINK_COUNT); @@ -78,6 +81,7 @@ fhandler_procsysvipc::exists () fileid () = entry - procsysvipc_tab; return entry->type; } + fileid () = -1; return virt_none; } |