diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2024-04-02 14:43:27 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2024-04-02 14:43:27 +0200 |
commit | a0a25849f9dda5cd3f2963bcc05563ab797c1e42 (patch) | |
tree | e31806803243c45fab1c661683987a689839078c /winsup/cygwin/fhandler/procnet.cc | |
parent | b7f5a33200a91ee76f5364280ad40bafedfab142 (diff) | |
download | newlib-a0a25849f9dda5cd3f2963bcc05563ab797c1e42.zip newlib-a0a25849f9dda5cd3f2963bcc05563ab797c1e42.tar.gz newlib-a0a25849f9dda5cd3f2963bcc05563ab797c1e42.tar.bz2 |
Cygwin: fhandler_virtual: move fileid to path_conv member
Commit 80f722e97cf7 ("Cygwin: opendir(3): move ENOTDIR check into main
function") introduced a bug in fhandler_virtual handling. While the
assertion that path_conv::check() already calls exists() and sets
FILE_ATTRIBUTE_DIRECTORY accordingly, the exists() function is called
on a fhandler_virtual object created for just this code snippet. The
side effect of this is that the fileid member in the calling
fhandler_virtual object is not set after path_conv::check().
Move the fhandler_virtual::fileid member to path_conv::_virt_fileid
and create matching path_conv::virt_fileid() and fhandler_virtual::fileid()
methods.
Let path_conv::check() propagate the fileid set in the local
fhandler_virtual::exists() call to its own _virt_fileid.
Use new fhandler_virtual::fileid() method throughout.
Fixes: 80f722e97cf7 ("Cygwin: opendir(3): move ENOTDIR check into main function")
Reported-by: Bruce Jerrick <bmj001@gmail.com>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/fhandler/procnet.cc')
-rw-r--r-- | winsup/cygwin/fhandler/procnet.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/winsup/cygwin/fhandler/procnet.cc b/winsup/cygwin/fhandler/procnet.cc index d512887..112aee8 100644 --- a/winsup/cygwin/fhandler/procnet.cc +++ b/winsup/cygwin/fhandler/procnet.cc @@ -56,7 +56,7 @@ fhandler_procnet::exists () { if (entry->type == virt_file && !get_adapters_addresses (NULL, AF_INET6)) return virt_none; - fileid = entry - procnet_tab; + fileid () = entry - procnet_tab; return entry->type; } return virt_none; @@ -159,7 +159,7 @@ fhandler_procnet::open (int flags, mode_t mode) goto out; } - fileid = entry - procnet_tab; + fileid () = entry - procnet_tab; if (!fill_filebuf ()) { res = 0; @@ -183,9 +183,9 @@ out: bool fhandler_procnet::fill_filebuf () { - if (procnet_tab[fileid].format_func) + if (procnet_tab[fileid ()].format_func) { - filesize = procnet_tab[fileid].format_func (NULL, filebuf); + filesize = procnet_tab[fileid ()].format_func (NULL, filebuf); return true; } return false; |