@@ -309,35 +309,43 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args)
309309 }
310310 } while (ret == WS_WANT_READ || ret == WS_WANT_WRITE ||
311311 ret == WS_CHAN_RXD || ret == WS_REKEYING );
312- if (ret != WS_SUCCESS )
313- err_sys ("Couldn't copy the file." );
312+ if (ret != WS_SUCCESS ) {
313+ fprintf (stderr , "Couldn't copy the file." );
314+ ((func_args * )args )-> return_code = 1 ;
315+ }
314316
315317 ret = wolfSSH_shutdown (ssh );
316318 /* do not continue on with shutdown process if peer already disconnected */
317319 if (ret != WS_CHANNEL_CLOSED && ret != WS_SOCKET_ERROR_E &&
318320 wolfSSH_get_error (ssh ) != WS_SOCKET_ERROR_E &&
319321 wolfSSH_get_error (ssh ) != WS_CHANNEL_CLOSED ) {
320322 if (ret != WS_SUCCESS ) {
321- err_sys ( "Sending the shutdown messages failed." );
323+ WLOG ( WS_LOG_DEBUG , "Sending the shutdown messages failed." );
322324 }
323- ret = wolfSSH_worker (ssh , NULL );
324- if (ret != WS_SUCCESS && ret != WS_CHANNEL_CLOSED ) {
325- err_sys ("Failed to listen for close messages from the peer." );
325+ else {
326+ ret = wolfSSH_worker (ssh , NULL );
327+ if (ret != WS_SUCCESS && ret != WS_CHANNEL_CLOSED ) {
328+ WLOG (WS_LOG_DEBUG ,
329+ "Failed to listen for close messages from the peer." );
330+ }
326331 }
327332 }
328333 WCLOSESOCKET (sockFd );
329334 wolfSSH_free (ssh );
330335 wolfSSH_CTX_free (ctx );
331336 if (ret != WS_SUCCESS && ret != WS_SOCKET_ERROR_E &&
332337 ret != WS_CHANNEL_CLOSED ) {
333- err_sys ("Closing scp stream failed. Connection could have been closed by peer" );
338+ WLOG (WS_LOG_DEBUG ,
339+ "Closing scp stream failed. Connection could have been closed by peer" );
334340 }
335341
336342 ClientFreeBuffers (pubKeyName , privKeyName , NULL );
337343#if !defined(WOLFSSH_NO_ECC ) && defined(FP_ECC ) && defined(HAVE_THREAD_LS )
338344 wc_ecc_fp_free (); /* free per thread cache */
339345#endif
340346
347+ if (ret != WS_SUCCESS )
348+ ((func_args * )args )-> return_code = 1 ;
341349 return 0 ;
342350}
343351
0 commit comments