hnakamur / go-scp

[Unmaintained] A scp client library written in Go
MIT License
41 stars 23 forks source link

ReceiveDir failes if filename has whitespace in it. #23

Closed danielwentland closed 3 years ago

danielwentland commented 3 years ago

I had a project last week where i had to download a whole directory structure. Which failed because i had some files with whitespace in filename. Seems like it fails in protocol.go line 196.

n, err := fmt.Fscanf(s.remReader, "%04o %d %s\n", &h.Mode, &h.Size, &h.Name)
if err != nil {
    return nil, fmt.Errorf("failed to read scp file message header: err=%s", err)
}

Fscan seperates on whitespaces and treats new line as whitespace.

Seems also to be connected to #10 Fscan cannot get file information from a dead link same as it gets the wrong file name if it has a whitespace in it.

hnakamur commented 3 years ago

Thanks for reporting an issue. Fixed in https://github.com/hnakamur/go-scp/pull/24