cyverse / gocommands

iRODS Command-line Tools written in Go
Other
28 stars 18 forks source link

Fix segfault when putting without supplying --encrypt/no_encrypt option #56

Closed mksanger closed 2 months ago

mksanger commented 3 months ago

When running put, I get

$ gocmd put -k [source] [destination]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x9be49a]

goroutine 1 [running]:
github.com/cyverse/gocommands/cmd/subcmd.(*PutCommand).requireEncryption(0xc0001d4340, {0x7ffecd34d65e, 0x34}, 0x14?, {0x0, 0x0})
        /github/workspace/cmd/subcmd/put.go:291 +0xfa
...

The cause of this is that when filesystem.Stat returns an error, the returned targetEntry is nil. GetDir should be passed the original targetPath, rather than trying to get the path from targetEntry here.

iychoi commented 2 months ago

Thank you for the fix!