4747 #include "src/misc.c"
4848#endif
4949
50+ #ifndef WOLFSSH_DEFAULT_EXTDATA_SZ
51+ #define WOLFSSH_DEFAULT_EXTDATA_SZ 128
52+ #endif
53+
5054#ifndef NO_FILESYSTEM
5155static int ScpFileIsDir (ScpSendCtx * ctx );
5256static int ScpPushDir (ScpSendCtx * ctx , const char * path , void * heap );
@@ -56,6 +60,23 @@ static int ScpPopDir(ScpSendCtx* ctx, void* heap);
5660const char scpError [] = "scp error: %s, %d" ;
5761const char scpState [] = "scp state: %s" ;
5862
63+
64+ static int _DumpExtendedData (WOLFSSH * ssh )
65+ {
66+ byte msg [WOLFSSH_DEFAULT_EXTDATA_SZ ];
67+ int msgSz ;
68+
69+ msgSz = wolfSSH_extended_data_read (ssh , msg , WOLFSSH_DEFAULT_EXTDATA_SZ - 1 );
70+ if (msgSz > 0 ) {
71+ msg [WOLFSSH_DEFAULT_EXTDATA_SZ - 1 ] = 0 ;
72+ fprintf (stderr , "%s" , msg );
73+ msgSz = WS_SUCCESS ;
74+ }
75+
76+ return msgSz ;
77+ }
78+
79+
5980int DoScpSink (WOLFSSH * ssh )
6081{
6182 int ret = WS_SUCCESS ;
@@ -584,6 +605,10 @@ int DoScpSource(WOLFSSH* ssh)
584605 if (ret == WS_SUCCESS )
585606 continue ;
586607 }
608+ if (ret == WS_EXTDATA ) {
609+ _DumpExtendedData (ssh );
610+ continue ;
611+ }
587612 if (ret < 0 ) {
588613 WLOG (WS_LOG_ERROR , scpError , "failed to send file" , ret );
589614 break ;
@@ -1470,7 +1495,10 @@ int ReceiveScpConfirmation(WOLFSSH* ssh)
14701495 msgSz = wolfSSH_stream_read (ssh , msg , DEFAULT_SCP_MSG_SZ );
14711496
14721497 if (msgSz < 0 ) {
1473- ret = msgSz ;
1498+ if (wolfSSH_get_error (ssh ) == WS_EXTDATA )
1499+ _DumpExtendedData (ssh );
1500+ else
1501+ ret = msgSz ;
14741502 } else if (msgSz > 1 ) {
14751503 /* null terminate */
14761504 msg [msgSz ] = 0x00 ;
0 commit comments