hnakamur / go-scp

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

ReceiveDir panic when trying to copy a file that link to a deleted one #10

Open meliot opened 6 years ago

meliot commented 6 years ago

As title said, ReceiveDir panic when I try to SCP a directory that contains link to files that no longer exists.

The code that perform the call is the following:

func ReceiveDir (srcDir string, outDir string) {
    err := scp.NewSCP(connection).ReceiveDir(srcDir, outDir, nil)
    if err != nil {
        log.Fatal("Unable to SCP directories: ", err)
        }
}

The error I get is: 2018/04/15 18:52:10 Unable to SCP directories: failed to read scp message header: err=failed to read scp start directory message header: err=newline in format does not match input

So I suppose the problem lies in this Fscanf: https://github.com/hnakamur/go-scp/blob/master/protocol.go#L213

I think the library should by default, or with a flag, ignore links to death files.

hnakamur commented 5 years ago

Sorry for being late. I tried to reproduce the problem at https://github.com/hnakamur/go-scp/commit/298399d7b1929931529336272d9c28a8f3bc3f73, but I got a different error.

sink_test.go:224: fail to ReceiveDir; failed to read scp message header: err=scp: /tmp/go-scp-TestReceiveDir-remote868529785/dead-link: No such file or directory

Could you tell me how to reproduce your problem? The vresion of sshd, OS, and distribution might help. Or could you write the failing test?

Thanks!