rename libssh2_error to the correct _libssh2_error
We reserve ^libssh2_ for public symbols and we use _libssh2 as prefix for internal ones. I fixed the intendation of all these edits with emacs afterwards, which then changed it slightly more than just _libssh2_error() expressions but I didn't see any obvious problems.
This commit is contained in:
326
src/scp.c
326
src/scp.c
@@ -47,78 +47,78 @@
|
||||
#define libssh2_shell_quotedsize(s) (3 * strlen(s) + 2)
|
||||
|
||||
/*
|
||||
This function quotes a string in a way suitable to be used with a
|
||||
shell, e.g. the file name
|
||||
one two
|
||||
becomes
|
||||
'one two'
|
||||
This function quotes a string in a way suitable to be used with a
|
||||
shell, e.g. the file name
|
||||
one two
|
||||
becomes
|
||||
'one two'
|
||||
|
||||
The resulting output string is crafted in a way that makes it usable
|
||||
with the two most common shell types: Bourne Shell derived shells
|
||||
(sh, ksh, ksh93, bash, zsh) and C-Shell derivates (csh, tcsh).
|
||||
The resulting output string is crafted in a way that makes it usable
|
||||
with the two most common shell types: Bourne Shell derived shells
|
||||
(sh, ksh, ksh93, bash, zsh) and C-Shell derivates (csh, tcsh).
|
||||
|
||||
The following special cases are handled:
|
||||
o If the string contains an apostrophy itself, the apostrophy
|
||||
character is written in quotation marks, e.g. "'".
|
||||
The shell cannot handle the syntax 'doesn\'t', so we close the
|
||||
current argument word, add the apostrophe in quotation marks "",
|
||||
and open a new argument word instead (_ indicate the input
|
||||
string characters):
|
||||
_____ _ _
|
||||
'doesn' "'" 't'
|
||||
The following special cases are handled:
|
||||
o If the string contains an apostrophy itself, the apostrophy
|
||||
character is written in quotation marks, e.g. "'".
|
||||
The shell cannot handle the syntax 'doesn\'t', so we close the
|
||||
current argument word, add the apostrophe in quotation marks "",
|
||||
and open a new argument word instead (_ indicate the input
|
||||
string characters):
|
||||
_____ _ _
|
||||
'doesn' "'" 't'
|
||||
|
||||
Sequences of apostrophes are combined in one pair of quotation marks:
|
||||
a'''b
|
||||
becomes
|
||||
_ ___ _
|
||||
'a'"'''"'b'
|
||||
Sequences of apostrophes are combined in one pair of quotation marks:
|
||||
a'''b
|
||||
becomes
|
||||
_ ___ _
|
||||
'a'"'''"'b'
|
||||
|
||||
o If the string contains an exclamation mark (!), the C-Shell
|
||||
interprets it as an event number. Using \! (not within quotation
|
||||
marks or single quotation marks) is a mechanism understood by
|
||||
both Bourne Shell and C-Shell.
|
||||
o If the string contains an exclamation mark (!), the C-Shell
|
||||
interprets it as an event number. Using \! (not within quotation
|
||||
marks or single quotation marks) is a mechanism understood by
|
||||
both Bourne Shell and C-Shell.
|
||||
|
||||
If a quotation was already started, the argument word is closed
|
||||
first:
|
||||
a!b
|
||||
If a quotation was already started, the argument word is closed
|
||||
first:
|
||||
a!b
|
||||
|
||||
become
|
||||
_ _ _
|
||||
'a'\!'b'
|
||||
become
|
||||
_ _ _
|
||||
'a'\!'b'
|
||||
|
||||
The result buffer must be large enough for the expanded result. A
|
||||
bad case regarding expansion is alternating characters and
|
||||
apostrophes:
|
||||
The result buffer must be large enough for the expanded result. A
|
||||
bad case regarding expansion is alternating characters and
|
||||
apostrophes:
|
||||
|
||||
a'b'c'd' (length 8) gets converted to
|
||||
'a'"'"'b'"'"'c'"'"'d'"'" (length 24)
|
||||
a'b'c'd' (length 8) gets converted to
|
||||
'a'"'"'b'"'"'c'"'"'d'"'" (length 24)
|
||||
|
||||
This is the worst case.
|
||||
This is the worst case.
|
||||
|
||||
Maximum length of the result:
|
||||
1 + 6 * (length(input) + 1) / 2) + 1
|
||||
Maximum length of the result:
|
||||
1 + 6 * (length(input) + 1) / 2) + 1
|
||||
|
||||
=> 3 * length(input) + 2
|
||||
=> 3 * length(input) + 2
|
||||
|
||||
Explanation:
|
||||
o leading apostrophe
|
||||
o one character / apostrophe pair (two characters) can get
|
||||
represented as 6 characters: a' -> a'"'"'
|
||||
o String terminator (+1)
|
||||
Explanation:
|
||||
o leading apostrophe
|
||||
o one character / apostrophe pair (two characters) can get
|
||||
represented as 6 characters: a' -> a'"'"'
|
||||
o String terminator (+1)
|
||||
|
||||
A result buffer three times the size of the input buffer + 2
|
||||
characters should be safe.
|
||||
A result buffer three times the size of the input buffer + 2
|
||||
characters should be safe.
|
||||
|
||||
References:
|
||||
o csh-compatible quotation (special handling for '!' etc.), see
|
||||
http://www.grymoire.com/Unix/Csh.html#toc-uh-10
|
||||
References:
|
||||
o csh-compatible quotation (special handling for '!' etc.), see
|
||||
http://www.grymoire.com/Unix/Csh.html#toc-uh-10
|
||||
|
||||
Return value:
|
||||
Length of the resulting string (not counting the terminating '\0'),
|
||||
or 0 in case of errors, e.g. result buffer too small
|
||||
Return value:
|
||||
Length of the resulting string (not counting the terminating '\0'),
|
||||
or 0 in case of errors, e.g. result buffer too small
|
||||
|
||||
Note: this function could possible be used elsewhere within libssh2, but
|
||||
until then it is kept static and in this source file.
|
||||
Note: this function could possible be used elsewhere within libssh2, but
|
||||
until then it is kept static and in this source file.
|
||||
*/
|
||||
|
||||
static unsigned
|
||||
@@ -234,20 +234,20 @@ libssh2_shell_quotearg(const char *path, unsigned char *buf,
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case UQSTRING:
|
||||
break;
|
||||
case QSTRING: /* Close quoted string */
|
||||
if (dst+1 >= endp)
|
||||
return 0;
|
||||
*dst++ = '"';
|
||||
break;
|
||||
case SQSTRING: /* Close single quoted string */
|
||||
if (dst+1 >= endp)
|
||||
return 0;
|
||||
*dst++ = '\'';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case UQSTRING:
|
||||
break;
|
||||
case QSTRING: /* Close quoted string */
|
||||
if (dst+1 >= endp)
|
||||
return 0;
|
||||
*dst++ = '"';
|
||||
break;
|
||||
case SQSTRING: /* Close single quoted string */
|
||||
if (dst+1 >= endp)
|
||||
return 0;
|
||||
*dst++ = '\'';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (dst+1 >= endp)
|
||||
@@ -285,9 +285,9 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
LIBSSH2_ALLOC(session, session->scpRecv_command_len);
|
||||
|
||||
if (!session->scpRecv_command) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate a command buffer for "
|
||||
"SCP session");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate a command buffer for "
|
||||
"SCP session");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -323,8 +323,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
session->scpRecv_state = libssh2_NB_state_idle;
|
||||
}
|
||||
else {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block starting up channel");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block starting up channel");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -339,8 +339,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
(char *) session->scpRecv_command,
|
||||
session->scpRecv_command_len);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block requesting SCP startup");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block requesting SCP startup");
|
||||
return NULL;
|
||||
} else if (rc) {
|
||||
LIBSSH2_FREE(session, session->scpRecv_command);
|
||||
@@ -361,8 +361,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
rc = _libssh2_channel_write(session->scpRecv_channel, 0,
|
||||
(char *) session->scpRecv_response, 1);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block sending initial wakeup");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block sending initial wakeup");
|
||||
return NULL;
|
||||
} else if (rc != 1) {
|
||||
goto scp_recv_error;
|
||||
@@ -386,13 +386,13 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
scpRecv_response +
|
||||
session->scpRecv_response_len, 1);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for SCP response");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for SCP response");
|
||||
return NULL;
|
||||
} else if (rc <= 0) {
|
||||
/* Timeout, give up */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Timed out waiting for SCP response");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Timed out waiting for SCP response");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
session->scpRecv_response_len++;
|
||||
@@ -402,8 +402,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
* Set this as the default error for here, if
|
||||
* we are successful it will be replaced
|
||||
*/
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid data in SCP response, missing Time data");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid data in SCP response, missing Time data");
|
||||
|
||||
session->scpRecv_err_len =
|
||||
_libssh2_channel_packet_data_len(session->
|
||||
@@ -426,12 +426,12 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
* it is already in the systems so it can't return
|
||||
* PACKET_EAGAIN
|
||||
*/
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Unknown error" );
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Unknown error" );
|
||||
}
|
||||
else
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"SCP protocol error");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"SCP protocol error");
|
||||
|
||||
/* TODO: for debugging purposes, the
|
||||
session->scpRecv_err_msg should be displayed here
|
||||
@@ -458,8 +458,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
&& (session->
|
||||
scpRecv_response[session->scpRecv_response_len - 1] !=
|
||||
'\n')) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid data in SCP response");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid data in SCP response");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -470,8 +470,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
if (session->scpRecv_response_len ==
|
||||
LIBSSH2_SCP_RESPONSE_BUFLEN) {
|
||||
/* You had your chance */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Unterminated response from SCP server");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Unterminated response from SCP server");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
/* Way too short to be an SCP response, or not done yet,
|
||||
@@ -493,9 +493,9 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
|
||||
if (session->scpRecv_response_len < 8) {
|
||||
/* EOL came too soon */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, "
|
||||
"too short" );
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, "
|
||||
"too short" );
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -504,9 +504,9 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
p = (unsigned char *) strchr((char *) s, ' ');
|
||||
if (!p || ((p - s) <= 0)) {
|
||||
/* No spaces or space in the wrong spot */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, "
|
||||
"malformed mtime");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, "
|
||||
"malformed mtime");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -515,15 +515,15 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
errno = 0;
|
||||
session->scpRecv_mtime = strtol((char *) s, NULL, 10);
|
||||
if (errno) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, invalid mtime");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, invalid mtime");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
s = (unsigned char *) strchr((char *) p, ' ');
|
||||
if (!s || ((s - p) <= 0)) {
|
||||
/* No spaces or space in the wrong spot */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, malformed mtime.usec");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, malformed mtime.usec");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -532,8 +532,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
p = (unsigned char *) strchr((char *) s, ' ');
|
||||
if (!p || ((p - s) <= 0)) {
|
||||
/* No spaces or space in the wrong spot */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, too short or malformed");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, too short or malformed");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -542,8 +542,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
errno = 0;
|
||||
session->scpRecv_atime = strtol((char *) s, NULL, 10);
|
||||
if (errno) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, invalid atime");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, invalid atime");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -558,8 +558,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
(char *) session->
|
||||
scpRecv_response, 1);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting to send SCP ACK");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting to send SCP ACK");
|
||||
return NULL;
|
||||
} else if (rc != 1) {
|
||||
goto scp_recv_error;
|
||||
@@ -595,20 +595,20 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
scpRecv_response +
|
||||
session->scpRecv_response_len, 1);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for SCP response");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for SCP response");
|
||||
return NULL;
|
||||
} else if (rc <= 0) {
|
||||
/* Timeout, give up */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Timed out waiting for SCP response");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Timed out waiting for SCP response");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
session->scpRecv_response_len++;
|
||||
|
||||
if (session->scpRecv_response[0] != 'C') {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -625,8 +625,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
|| (session->
|
||||
scpRecv_response[session->scpRecv_response_len - 1] >
|
||||
126))) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid data in SCP response");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid data in SCP response");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -637,8 +637,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
if (session->scpRecv_response_len ==
|
||||
LIBSSH2_SCP_RESPONSE_BUFLEN) {
|
||||
/* You had your chance */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Unterminated response from SCP server");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Unterminated response from SCP server");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
/* Way too short to be an SCP response, or not done yet,
|
||||
@@ -661,8 +661,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
|
||||
if (session->scpRecv_response_len < 6) {
|
||||
/* EOL came too soon */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, too short");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, too short");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -671,8 +671,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
p = strchr(s, ' ');
|
||||
if (!p || ((p - s) <= 0)) {
|
||||
/* No spaces or space in the wrong spot */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, malformed mode");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, malformed mode");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -681,16 +681,16 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
errno = 0;
|
||||
session->scpRecv_mode = strtol(s, &e, 8);
|
||||
if ((e && *e) || errno) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, invalid mode");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, invalid mode");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
s = strchr(p, ' ');
|
||||
if (!s || ((s - p) <= 0)) {
|
||||
/* No spaces or space in the wrong spot */
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, too short or malformed");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, too short or malformed");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -699,8 +699,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
errno = 0;
|
||||
session->scpRecv_size = scpsize_strtol(p, &e, 10);
|
||||
if ((e && *e) || errno) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, invalid size");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid response from SCP server, invalid size");
|
||||
goto scp_recv_error;
|
||||
}
|
||||
|
||||
@@ -715,8 +715,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
(char *) session->
|
||||
scpRecv_response, 1);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block sending SCP ACK");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block sending SCP ACK");
|
||||
return NULL;
|
||||
} else if (rc != 1) {
|
||||
goto scp_recv_error;
|
||||
@@ -789,8 +789,8 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
session->scpSend_command =
|
||||
LIBSSH2_ALLOC(session, session->scpSend_command_len);
|
||||
if (!session->scpSend_command) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate a command buffer for scp session");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate a command buffer for scp session");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -826,8 +826,8 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
session->scpSend_state = libssh2_NB_state_idle;
|
||||
}
|
||||
else {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block starting up channel");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block starting up channel");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -842,8 +842,8 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
(char *) session->scpSend_command,
|
||||
session->scpSend_command_len);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block requesting SCP startup");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block requesting SCP startup");
|
||||
return NULL;
|
||||
}
|
||||
else if (rc) {
|
||||
@@ -851,8 +851,8 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
through */
|
||||
LIBSSH2_FREE(session, session->scpSend_command);
|
||||
session->scpSend_command = NULL;
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Unknown error while getting error string");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Unknown error while getting error string");
|
||||
goto scp_send_error;
|
||||
}
|
||||
LIBSSH2_FREE(session, session->scpSend_command);
|
||||
@@ -866,12 +866,12 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
rc = _libssh2_channel_read(session->scpSend_channel, 0,
|
||||
(char *) session->scpSend_response, 1);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for response from remote");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for response from remote");
|
||||
return NULL;
|
||||
} else if ((rc <= 0) || (session->scpSend_response[0] != 0)) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid ACK response from remote");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid ACK response from remote");
|
||||
goto scp_send_error;
|
||||
}
|
||||
|
||||
@@ -895,12 +895,12 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
(char *) session->scpSend_response,
|
||||
session->scpSend_response_len);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block sending time data for SCP file");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block sending time data for SCP file");
|
||||
return NULL;
|
||||
} else if (rc != (int)session->scpSend_response_len) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
|
||||
"Unable to send time data for SCP file");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
|
||||
"Unable to send time data for SCP file");
|
||||
goto scp_send_error;
|
||||
}
|
||||
|
||||
@@ -912,12 +912,12 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
rc = _libssh2_channel_read(session->scpSend_channel, 0,
|
||||
(char *) session->scpSend_response, 1);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for response");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for response");
|
||||
return NULL;
|
||||
} else if ((rc <= 0) || (session->scpSend_response[0] != 0)) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid ACK response from remote");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid ACK response from remote");
|
||||
goto scp_send_error;
|
||||
}
|
||||
|
||||
@@ -953,12 +953,12 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
(char *) session->scpSend_response,
|
||||
session->scpSend_response_len);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block send core file data for SCP file");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block send core file data for SCP file");
|
||||
return NULL;
|
||||
} else if (rc != (int)session->scpSend_response_len) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
|
||||
"Unable to send core file data for SCP file");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
|
||||
"Unable to send core file data for SCP file");
|
||||
goto scp_send_error;
|
||||
}
|
||||
|
||||
@@ -970,20 +970,20 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
rc = _libssh2_channel_read(session->scpSend_channel, 0,
|
||||
(char *) session->scpSend_response, 1);
|
||||
if (rc == PACKET_EAGAIN) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for response");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block waiting for response");
|
||||
return NULL;
|
||||
} else if (rc <= 0) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid ACK response from remote");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid ACK response from remote");
|
||||
goto scp_send_error;
|
||||
} else if (session->scpSend_response[0] != 0) {
|
||||
/*
|
||||
* Set this as the default error for here, if
|
||||
* we are successful it will be replaced
|
||||
*/
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid ACK response from remote");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"Invalid ACK response from remote");
|
||||
|
||||
session->scpSend_err_len =
|
||||
_libssh2_channel_packet_data_len(session->scpSend_channel, 0);
|
||||
@@ -1007,8 +1007,8 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
session->scpSend_err_msg = NULL;
|
||||
}
|
||||
else
|
||||
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"failed waiting for ACK");
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
|
||||
"failed waiting for ACK");
|
||||
goto scp_send_error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user