explain mechanics of use-after-close protection

This commit is contained in:
Cassondra Foesch 2024-02-06 08:34:29 +00:00
parent e808920da0
commit ba3d6ab7c6
1 changed files with 3 additions and 1 deletions

View File

@ -999,9 +999,11 @@ func (f *File) Close() error {
return os.ErrClosed
}
// When `openssh-portable/sftp-server.c` is doing `handle_close`,
// The design principle here is that when `openssh-portable/sftp-server.c` is doing `handle_close`,
// it will unconditionally mark the handle as unused,
// so we need to also unconditionally mark this handle as invalid.
// By invalidating our local copy of the handle,
// we ensure that there cannot be any erroneous use-after-close requests sent after Close.
handle := f.handle
f.handle = ""