mirror of https://github.com/pkg/sftp.git
explain mechanics of use-after-close protection
This commit is contained in:
parent
e808920da0
commit
ba3d6ab7c6
|
|
@ -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 = ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue