diff --git a/docs/libssh2_scp_recv.3 b/docs/libssh2_scp_recv.3 index 93bcee86..df04aea4 100644 --- a/docs/libssh2_scp_recv.3 +++ b/docs/libssh2_scp_recv.3 @@ -28,6 +28,8 @@ Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors. .SH ERRORS \fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed. +\fILIBSSH2_ERROR_INVAL\fP - Invalid argument used in function call. + \fILIBSSH2_ERROR_SCP_PROTOCOL\fP - \fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would diff --git a/docs/libssh2_scp_recv2.3 b/docs/libssh2_scp_recv2.3 index c3a27c2c..4408b4d5 100644 --- a/docs/libssh2_scp_recv2.3 +++ b/docs/libssh2_scp_recv2.3 @@ -25,6 +25,8 @@ Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors. .SH ERRORS \fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed. +\fILIBSSH2_ERROR_INVAL\fP - Invalid argument used in function call. + \fILIBSSH2_ERROR_SCP_PROTOCOL\fP - \fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would diff --git a/docs/libssh2_scp_send64.3 b/docs/libssh2_scp_send64.3 index 65611037..401f99bc 100644 --- a/docs/libssh2_scp_send64.3 +++ b/docs/libssh2_scp_send64.3 @@ -37,6 +37,8 @@ Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors. .SH ERRORS \fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed. +\fILIBSSH2_ERROR_INVAL\fP - Invalid argument used in function call. + \fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket. \fILIBSSH2_ERROR_SCP_PROTOCOL\fP - diff --git a/src/scp.c b/src/scp.c index e39d7b5d..7a92635d 100644 --- a/src/scp.c +++ b/src/scp.c @@ -284,6 +284,12 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, libssh2_struct_stat * sb) int tmp_err_code; const char *tmp_err_msg; + if(!path) { + _libssh2_error(session, LIBSSH2_ERROR_INVAL, + "Path argument can not be null"); + return NULL; + } + if(session->scpRecv_state == libssh2_NB_state_idle) { session->scpRecv_mode = 0; session->scpRecv_size = 0; @@ -860,6 +866,12 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode, int tmp_err_code; const char *tmp_err_msg; + if(!path) { + _libssh2_error(session, LIBSSH2_ERROR_INVAL, + "Path argument can not be null"); + return NULL; + } + if(session->scpSend_state == libssh2_NB_state_idle) { session->scpSend_command_len = _libssh2_shell_quotedsize(path) + sizeof("scp -t ") +