mirror of https://github.com/wolfSSL/wolfssh.git
When scp receives a string in STDERR, print it out.
parent
bb6e6e2ba8
commit
caedd5339c
|
|
@ -47,6 +47,10 @@
|
|||
#include "src/misc.c"
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSH_DEFAULT_EXTDATA_SZ
|
||||
#define WOLFSSH_DEFAULT_EXTDATA_SZ 128
|
||||
#endif
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
static int ScpFileIsDir(ScpSendCtx* ctx);
|
||||
static int ScpPushDir(ScpSendCtx* ctx, const char* path, void* heap);
|
||||
|
|
@ -56,6 +60,23 @@ static int ScpPopDir(ScpSendCtx* ctx, void* heap);
|
|||
const char scpError[] = "scp error: %s, %d";
|
||||
const char scpState[] = "scp state: %s";
|
||||
|
||||
|
||||
static int _DumpExtendedData(WOLFSSH* ssh)
|
||||
{
|
||||
byte msg[WOLFSSH_DEFAULT_EXTDATA_SZ];
|
||||
int msgSz;
|
||||
|
||||
msgSz = wolfSSH_extended_data_read(ssh, msg, WOLFSSH_DEFAULT_EXTDATA_SZ-1);
|
||||
if (msgSz > 0) {
|
||||
msg[WOLFSSH_DEFAULT_EXTDATA_SZ - 1] = 0;
|
||||
fprintf(stderr, "%s", msg);
|
||||
msgSz = WS_SUCCESS;
|
||||
}
|
||||
|
||||
return msgSz;
|
||||
}
|
||||
|
||||
|
||||
int DoScpSink(WOLFSSH* ssh)
|
||||
{
|
||||
int ret = WS_SUCCESS;
|
||||
|
|
@ -584,6 +605,10 @@ int DoScpSource(WOLFSSH* ssh)
|
|||
if (ret == WS_SUCCESS)
|
||||
continue;
|
||||
}
|
||||
if (ret == WS_EXTDATA) {
|
||||
_DumpExtendedData(ssh);
|
||||
continue;
|
||||
}
|
||||
if (ret < 0) {
|
||||
WLOG(WS_LOG_ERROR, scpError, "failed to send file", ret);
|
||||
break;
|
||||
|
|
@ -1470,7 +1495,10 @@ int ReceiveScpConfirmation(WOLFSSH* ssh)
|
|||
msgSz = wolfSSH_stream_read(ssh, msg, DEFAULT_SCP_MSG_SZ);
|
||||
|
||||
if (msgSz < 0) {
|
||||
ret = msgSz;
|
||||
if (wolfSSH_get_error(ssh) == WS_EXTDATA)
|
||||
_DumpExtendedData(ssh);
|
||||
else
|
||||
ret = msgSz;
|
||||
} else if (msgSz > 1) {
|
||||
/* null terminate */
|
||||
msg[msgSz] = 0x00;
|
||||
|
|
|
|||
Loading…
Reference in New Issue