File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -1175,7 +1175,7 @@ func (c *Client) transfer() (err error) {
11751175 }
11761176 }
11771177
1178- if c .Options .Stdout && ! c .Options .IsSender {
1178+ if c .Options .Stdout && ! c .Options .IsSender && len ( c . FilesToTransfer ) > 0 && c . FilesToTransferCurrentNum < len ( c . FilesToTransfer ) {
11791179 pathToFile := path .Join (
11801180 c .FilesToTransfer [c .FilesToTransferCurrentNum ].FolderRemote ,
11811181 c .FilesToTransfer [c .FilesToTransferCurrentNum ].Name ,
Original file line number Diff line number Diff line change @@ -368,6 +368,34 @@ func TestCrocError(t *testing.T) {
368368 assert .NotNil (t , err )
369369}
370370
371+ func TestReceiverStdoutWithInvalidSecret (t * testing.T ) {
372+ // Test for issue: panic when receiving with --stdout and invalid CROC_SECRET
373+ // This should fail gracefully without panicking
374+ log .SetLevel ("warn" )
375+ receiver , err := New (Options {
376+ IsSender : false ,
377+ SharedSecret : "invalid-secret-12345" ,
378+ Debug : true ,
379+ RelayAddress : "127.0.0.1:8281" ,
380+ RelayPassword : "pass123" ,
381+ Stdout : true , // This is the key flag that triggered the panic
382+ NoPrompt : true ,
383+ DisableLocal : true ,
384+ Curve : "siec" ,
385+ Overwrite : true ,
386+ })
387+ if err != nil {
388+ t .Errorf ("failed to create receiver: %v" , err )
389+ return
390+ }
391+
392+ // This should fail but not panic
393+ err = receiver .Receive ()
394+ // We expect an error since the secret is invalid and no sender is present
395+ assert .NotNil (t , err )
396+ log .Debugf ("Expected error occurred: %v" , err )
397+ }
398+
371399func TestCleanUp (t * testing.T ) {
372400 // windows allows files to be deleted only if they
373401 // are not open by another program so the remove actions
You can’t perform that action at this time.
0 commit comments