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

error reading response: unexpected EOF while storing a 0 file size using TLS #63

Open
ior308 opened this issue Nov 8, 2022 · 3 comments

Comments

@ior308
Copy link

ior308 commented Nov 8, 2022

Dear,

opening a local file of 0 bytes and storing to vsftpd via TLS, I got this error:

error reading response: unexpected EOF

Without TLS it works well. Any Idea ?

Best regards

@ior308
Copy link
Author

ior308 commented Nov 8, 2022

Here the output vsftpd side:
Tue Nov 8 08:27:04 2022 [pid 351212] CONNECT: Client "::ffff:192.168.1.122"
Tue Nov 8 08:27:04 2022 [pid 351212] FTP response: Client "::ffff:192.168.1.122", "220 (vsFTPd 3.0.3)"
Tue Nov 8 08:27:04 2022 [pid 351212] FTP command: Client "::ffff:192.168.1.122", "AUTH TLS"
Tue Nov 8 08:27:04 2022 [pid 351212] FTP response: Client "::ffff:192.168.1.122", "234 Proceed with negotiation."
Tue Nov 8 08:27:04 2022 [pid 351212] FTP command: Client "::ffff:192.168.1.122", "USER root"
Tue Nov 8 08:27:04 2022 [pid 351212] [root] FTP response: Client "::ffff:192.168.1.122", "331 Please specify the password."
Tue Nov 8 08:27:04 2022 [pid 351212] [root] FTP command: Client "::ffff:192.168.1.122", "PASS "
Tue Nov 8 08:27:04 2022 [pid 351211] [root] OK LOGIN: Client "::ffff:192.168.1.122"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", "230 Login successful."
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP command: Client "::ffff:192.168.1.122", "PBSZ 0"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", "200 PBSZ set to 0."
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP command: Client "::ffff:192.168.1.122", "PROT P"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", "200 PROT now Private."
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP command: Client "::ffff:192.168.1.122", "FEAT"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", "211-Features:"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " AUTH TLS\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " EPRT\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " EPSV\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " MDTM\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " PASV\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " PBSZ\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " PROT\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " REST STREAM\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " SIZE\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " TVFS\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", " UTF8\x0D\x0A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", "211 End"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP command: Client "::ffff:192.168.1.122", "TYPE A"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", "200 Switching to ASCII mode."
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP command: Client "::ffff:192.168.1.122", "PASV"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", "227 Entering Passive Mode (192,168,1,122,190,143)."
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP command: Client "::ffff:192.168.1.122", "STOR msg-dst.txt"
Tue Nov 8 08:27:04 2022 [pid 351216] [root] FTP response: Client "::ffff:192.168.1.122", "150 Ok to send data."

@ior308
Copy link
Author

ior308 commented Nov 8, 2022

And here some debug I added while storing client side, when does not work and when works (without TLS):

7 220 (vsFTPd 3.0.3)
7 234 Proceed with negotiation.
7 331 Please specify the password.
7 230 Login successful.
7 200 PBSZ set to 0.
7 200 PROT now Private.
7 211 Features:
AUTH TLS
EPRT
EPSV
MDTM
PASV
PBSZ
PROT
REST STREAM
SIZE
TVFS
UTF8
End
7 200 Switching to ASCII mode.
7 227 Entering Passive Mode (192,168,1,122,190,143).
7 150 Ok to send data.
io.Copy: 0
7 0 error reading response: unexpected EOF
6 0 0 error reading response: unexpected EOF
4: error reading response: unexpected EOF
panic: error reading response: unexpected EOF


7 220 (vsFTPd 3.0.3)
7 331 Please specify the password.
7 230 Login successful.
7 211 Features:
EPRT
EPSV
MDTM
PASV
REST STREAM
SIZE
TVFS
UTF8
End
7 200 Switching to ASCII mode.
7 227 Entering Passive Mode (192,168,1,122,186,107).
7 150 Ok to send data.
io.Copy: 0
7 226 Transfer complete.
8

@ior308
Copy link
Author

ior308 commented Nov 8, 2022

With TLS, it seems that io.copy of zero bytes is ignored. Adding a fake write of zero it works ?!

transfer.go
...

func (c *Client) transferFromOffset
...
n, err := io.Copy(dest, src)
dest.Write([]byte{})

..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant