Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - abort can be called without passing ownership to data_stream #66

Closed
clonejo opened this issue Jan 3, 2024 · 1 comment · Fixed by #67
Closed

[BUG] - abort can be called without passing ownership to data_stream #66

clonejo opened this issue Jan 3, 2024 · 1 comment · Fixed by #67
Assignees
Labels
bug Something isn't working

Comments

@clonejo
Copy link
Contributor

clonejo commented Jan 3, 2024

Description

I had trouble with using ImplAsyncFtpStream::abort() correctly. Apparently it is possible to only pass a mutable reference for data_stream instead of full ownership, so the drop does not work.

Steps to reproduce

let _ = env_logger::builder().is_test(true).try_init();
use suppaftp::{AsyncFtpStream, Mode};
let mut ftp_stream = AsyncFtpStream::connect("127.0.0.1:1234").await?;
ftp_stream.login("anonymous", "anonymous").await?;
ftp_stream.set_mode(Mode::ExtendedPassive);
let mut stream = ftp_stream.retr_as_stream("foo").await?;
// only pass &mut:
ftp_stream.abort(&mut stream).await?;
// this code will never actually be reached:
loop {
    dbg!();
}

Expected behaviour

abort() does not block indefinitely, or rather, it should be impossible to pass a reference here.

Environment

  • OS: Arch
  • Architecture: x86_64
  • Rust version: 1.76.0-beta.1
  • library version: v5.2.2
  • Protocol used: FTP
  • Remote server version and name: vsftpd 3.0.3

Additional information

Last lines from trace log:

[2024-01-03T00:50:29Z DEBUG suppaftp::async_ftp] Aborting active file transfer
[2024-01-03T00:50:29Z TRACE suppaftp::async_ftp] CC OUT: ABOR
[2024-01-03T00:50:29Z TRACE suppaftp::async_ftp] dropped stream
[2024-01-03T00:50:29Z TRACE polling::epoll] modify: epoll_fd=10, fd=9, ev=Event { key: 0, readable: true, writable: false }
@clonejo clonejo added the bug Something isn't working label Jan 3, 2024
@clonejo
Copy link
Contributor Author

clonejo commented Jan 5, 2024

Similarly, ImplAsyncFtpStream::quit() can be called on a &mut, and the ftp stream will be broken afterwards.

@veeso veeso closed this as completed in #67 Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants