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

hash: ensure to close the file in any case #213

Merged
merged 1 commit into from
Dec 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion handle_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@ func (c *clientHandler) computeHashForFile(filePath string, algo HASHAlgo, start
return "", err
}

defer c.closeUnchecked(file) // we ignore close error here

if start > 0 {
_, err = file.Seek(start, io.SeekStart)
if err != nil {
Expand All @@ -656,7 +658,6 @@ func (c *clientHandler) computeHashForFile(filePath string, algo HASHAlgo, start
}

_, err = io.CopyN(h, file, end-start)
defer c.closeUnchecked(file) // we ignore close error here

if err != nil && err != io.EOF {
return "", err
Expand Down
6 changes: 3 additions & 3 deletions transfer_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import (
)

func (c *clientHandler) handlePORT(param string) error {
command := c.GetLastCommand()

if c.server.settings.DisableActiveMode {
c.writeMessage(StatusServiceNotAvailable, "PORT command is disabled")
c.writeMessage(StatusServiceNotAvailable, fmt.Sprintf("%v command is disabled", command))

return nil
}

var err error
var raddr *net.TCPAddr

command := c.GetLastCommand()

if command == "EPRT" {
raddr, err = parseEPRTAddr(param)
} else { // PORT
Expand Down