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:
Daniel Stenberg 2010-04-16 00:18:51 +02:00
parent 9cc824e27b
commit 1adcb5234f
17 changed files with 1083 additions and 1083 deletions

View File

@ -618,7 +618,7 @@ libssh2_agent_init(LIBSSH2_SESSION *session)
agent = LIBSSH2_ALLOC(session, sizeof *agent);
if (!agent) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate space for agent connection");
return NULL;
}

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
* Copyright (c) 2008-2009 by Daniel Stenberg
* Copyright (c) 2008-2010 by Daniel Stenberg
*
* All rights reserved.
*
@ -155,7 +155,7 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
session->open_channel =
LIBSSH2_ALLOC(session, sizeof(LIBSSH2_CHANNEL));
if (!session->open_channel) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate space for channel data");
return NULL;
}
@ -165,7 +165,7 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
session->open_channel->channel_type =
LIBSSH2_ALLOC(session, channel_type_len);
if (!session->open_channel->channel_type) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Failed allocating memory for channel type name");
LIBSSH2_FREE(session, session->open_channel);
session->open_channel = NULL;
@ -187,7 +187,7 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
s = session->open_packet =
LIBSSH2_ALLOC(session, session->open_packet_len);
if (!session->open_packet) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate temporary space for packet");
goto channel_error;
}
@ -219,11 +219,11 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
rc = _libssh2_transport_write(session, session->open_packet,
session->open_packet_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending channel-open request");
return NULL;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send channel-open request");
goto channel_error;
}
@ -239,7 +239,7 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
channel_type_len, 4,
&session->open_packet_requirev_state);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
return NULL;
} else if (rc) {
goto channel_error;
@ -273,7 +273,7 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
}
if (session->open_data[0] == SSH_MSG_CHANNEL_OPEN_FAILURE) {
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Channel open failure");
}
}
@ -368,7 +368,7 @@ channel_direct_tcpip(LIBSSH2_SESSION * session, const char *host,
s = session->direct_message =
LIBSSH2_ALLOC(session, session->direct_message_len);
if (!session->direct_message) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for direct-tcpip connection");
return NULL;
}
@ -461,7 +461,7 @@ channel_forward_listen(LIBSSH2_SESSION * session, const char *host,
s = session->fwdLstn_packet =
LIBSSH2_ALLOC(session, session->fwdLstn_packet_len);
if (!session->fwdLstn_packet) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memeory for setenv packet");
return NULL;
}
@ -487,12 +487,12 @@ channel_forward_listen(LIBSSH2_SESSION * session, const char *host,
rc = _libssh2_transport_write(session, session->fwdLstn_packet,
session->fwdLstn_packet_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending global-request packet for "
"forward listen request");
return NULL;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send global-request packet for forward "
"listen request");
LIBSSH2_FREE(session, session->fwdLstn_packet);
@ -511,10 +511,10 @@ channel_forward_listen(LIBSSH2_SESSION * session, const char *host,
0, NULL, 0,
&session->fwdLstn_packet_requirev_state);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
return NULL;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_PROTO, "Unknown");
_libssh2_error(session, LIBSSH2_ERROR_PROTO, "Unknown");
session->fwdLstn_state = libssh2_NB_state_idle;
return NULL;
}
@ -524,7 +524,7 @@ channel_forward_listen(LIBSSH2_SESSION * session, const char *host,
listener = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_LISTENER));
if (!listener) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for listener queue");
LIBSSH2_FREE(session, data);
session->fwdLstn_state = libssh2_NB_state_idle;
@ -535,7 +535,7 @@ channel_forward_listen(LIBSSH2_SESSION * session, const char *host,
listener->host =
LIBSSH2_ALLOC(session, session->fwdLstn_host_len + 1);
if (!listener->host) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for listener queue");
LIBSSH2_FREE(session, listener);
LIBSSH2_FREE(session, data);
@ -571,7 +571,7 @@ channel_forward_listen(LIBSSH2_SESSION * session, const char *host,
if (data[0] == SSH_MSG_REQUEST_FAILURE) {
LIBSSH2_FREE(session, data);
libssh2_error(session, LIBSSH2_ERROR_REQUEST_DENIED,
_libssh2_error(session, LIBSSH2_ERROR_REQUEST_DENIED,
"Unable to complete request for forward-listen");
session->fwdLstn_state = libssh2_NB_state_idle;
return NULL;
@ -626,7 +626,7 @@ static int channel_forward_cancel(LIBSSH2_LISTENER *listener)
s = packet = LIBSSH2_ALLOC(session, packet_len);
if (!packet) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memeory for setenv packet");
return LIBSSH2_ERROR_ALLOC;
}
@ -657,7 +657,7 @@ static int channel_forward_cancel(LIBSSH2_LISTENER *listener)
return rc;
}
else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send global-request packet for forward "
"listen request");
LIBSSH2_FREE(session, packet);
@ -736,11 +736,11 @@ channel_forward_accept(LIBSSH2_LISTENER *listener)
}
if (rc == PACKET_EAGAIN) {
libssh2_error(listener->session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(listener->session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting for packet");
}
else
libssh2_error(listener->session, LIBSSH2_ERROR_CHANNEL_UNKNOWN,
_libssh2_error(listener->session, LIBSSH2_ERROR_CHANNEL_UNKNOWN,
"Channel not found");
return NULL;
}
@ -793,7 +793,7 @@ static int channel_setenv(LIBSSH2_CHANNEL *channel,
s = channel->setenv_packet =
LIBSSH2_ALLOC(session, channel->setenv_packet_len);
if (!channel->setenv_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memeory "
"for setenv packet");
}
@ -830,7 +830,7 @@ static int channel_setenv(LIBSSH2_CHANNEL *channel,
LIBSSH2_FREE(session, channel->setenv_packet);
channel->setenv_packet = NULL;
channel->setenv_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send channel-request packet for "
"setenv request");
}
@ -865,7 +865,7 @@ static int channel_setenv(LIBSSH2_CHANNEL *channel,
}
channel->setenv_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED,
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED,
"Unable to complete request for channel-setenv");
}
@ -920,7 +920,7 @@ static int channel_request_pty(LIBSSH2_CHANNEL *channel,
s = channel->reqPTY_packet =
LIBSSH2_ALLOC(session, channel->reqPTY_packet_len);
if (!channel->reqPTY_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for pty-request");
}
@ -969,7 +969,7 @@ static int channel_request_pty(LIBSSH2_CHANNEL *channel,
LIBSSH2_FREE(session, channel->reqPTY_packet);
channel->reqPTY_packet = NULL;
channel->reqPTY_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to send pty-request packet");
}
LIBSSH2_FREE(session, channel->reqPTY_packet);
@ -1000,7 +1000,7 @@ static int channel_request_pty(LIBSSH2_CHANNEL *channel,
LIBSSH2_FREE(session, data);
channel->reqPTY_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED,
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED,
"Unable to complete request for channel request-pty");
}
@ -1046,7 +1046,7 @@ channel_request_pty_size(LIBSSH2_CHANNEL * channel, int width,
LIBSSH2_ALLOC(session, channel->reqPTY_packet_len);
if (!channel->reqPTY_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for pty-request");
}
@ -1080,7 +1080,7 @@ channel_request_pty_size(LIBSSH2_CHANNEL * channel, int width,
LIBSSH2_FREE(session, channel->reqPTY_packet);
channel->reqPTY_packet = NULL;
channel->reqPTY_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to send window-change packet");
}
LIBSSH2_FREE(session, channel->reqPTY_packet);
@ -1150,7 +1150,7 @@ channel_x11_req(LIBSSH2_CHANNEL *channel, int single_connection,
s = channel->reqX11_packet =
LIBSSH2_ALLOC(session, channel->reqX11_packet_len);
if (!channel->reqX11_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for pty-request");
}
@ -1205,7 +1205,7 @@ channel_x11_req(LIBSSH2_CHANNEL *channel, int single_connection,
LIBSSH2_FREE(session, channel->reqX11_packet);
channel->reqX11_packet = NULL;
channel->reqX11_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to send x11-req packet");
}
LIBSSH2_FREE(session, channel->reqX11_packet);
@ -1224,7 +1224,7 @@ channel_x11_req(LIBSSH2_CHANNEL *channel, int single_connection,
return rc;
} else if (rc) {
channel->reqX11_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"waiting for x11-req response packet");
}
@ -1236,7 +1236,7 @@ channel_x11_req(LIBSSH2_CHANNEL *channel, int single_connection,
}
LIBSSH2_FREE(session, data);
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED,
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED,
"Unable to complete request for channel x11-req");
}
@ -1293,7 +1293,7 @@ _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
s = channel->process_packet =
LIBSSH2_ALLOC(session, channel->process_packet_len);
if (!channel->process_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory "
"for channel-process request");
}
@ -1328,7 +1328,7 @@ _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
LIBSSH2_FREE(session, channel->process_packet);
channel->process_packet = NULL;
channel->process_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to send channel request");
}
LIBSSH2_FREE(session, channel->process_packet);
@ -1347,7 +1347,7 @@ _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
return rc;
} else if (rc) {
channel->process_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Failed waiting for channel success");
}
@ -1360,7 +1360,7 @@ _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
LIBSSH2_FREE(session, data);
channel->process_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED,
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED,
"Unable to complete request for "
"channel-process-startup");
}
@ -1550,7 +1550,7 @@ _libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel,
}
else if (rc) {
channel->adjust_queue = adjustment;
return libssh2_error(channel->session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(channel->session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send transfer-window adjustment "
"packet, deferring");
}
@ -1715,7 +1715,7 @@ ssize_t _libssh2_channel_read(LIBSSH2_CHANNEL *channel, int stream_id,
rc = _libssh2_transport_read(session);
if ((rc < 0) && (rc != PACKET_EAGAIN))
return libssh2_error(session, rc, "transport read");
return _libssh2_error(session, rc, "transport read");
/*
* =============================== NOTE ===============================
@ -1949,12 +1949,12 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
stream_id);
if (channel->local.close) {
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_CLOSED,
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_CLOSED,
"We've already closed this channel");
}
if (channel->local.eof) {
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_EOF_SENT,
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_EOF_SENT,
"EOF has already been received, "
"data might be ignored");
}
@ -1965,7 +1965,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
channel->write_packet =
LIBSSH2_ALLOC(session, channel->write_packet_len);
if (!channel->write_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocte space "
"for data transmission packet");
}
@ -2046,14 +2046,14 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
_libssh2_transport_drain(session);
goto _channel_write_done;
}
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to send channel data");
}
else if (rc) {
LIBSSH2_FREE(session, channel->write_packet);
channel->write_packet = NULL;
channel->write_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to send channel data");
}
/* Shrink local window size */
@ -2114,7 +2114,7 @@ static int channel_send_eof(LIBSSH2_CHANNEL *channel)
return rc;
}
else if (rc) {
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send EOF on channel");
}
channel->local.eof = 1;
@ -2250,7 +2250,7 @@ channel_close(LIBSSH2_CHANNEL * channel)
return retcode;
} else if (retcode) {
channel->close_state = libssh2_NB_state_idle;
return libssh2_error(session, retcode,
return _libssh2_error(session, retcode,
"Unable to send close-channel request");
}
@ -2307,7 +2307,7 @@ static int channel_wait_closed(LIBSSH2_CHANNEL *channel)
int rc;
if (!libssh2_channel_eof(channel)) {
return libssh2_error(session, LIBSSH2_ERROR_INVAL,
return _libssh2_error(session, LIBSSH2_ERROR_INVAL,
"libssh2_channel_wait_closed() invoked when "
"channel is not in EOF state");
}

View File

@ -122,7 +122,7 @@ comp_method_zlib_init(LIBSSH2_SESSION * session, int compress,
strm = LIBSSH2_ALLOC(session, sizeof(z_stream));
if (!strm) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"zlib compression/decompression");
}
@ -185,7 +185,7 @@ comp_method_zlib_comp(LIBSSH2_SESSION * session,
out = (char *) strm->next_out;
strm->avail_out = out_maxlen;
if (!strm->next_out) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate compression/decompression "
"buffer");
}
@ -199,7 +199,7 @@ comp_method_zlib_comp(LIBSSH2_SESSION * session,
}
if (status != Z_OK) {
LIBSSH2_FREE(session, out);
return libssh2_error(session, LIBSSH2_ERROR_ZLIB,
return _libssh2_error(session, LIBSSH2_ERROR_ZLIB,
"compress/decompression failure");
}
if (strm->avail_in) {
@ -211,14 +211,14 @@ comp_method_zlib_comp(LIBSSH2_SESSION * session,
if ((out_maxlen > (int) payload_limit) && !compress && limiter++) {
LIBSSH2_FREE(session, out);
return libssh2_error(session, LIBSSH2_ERROR_ZLIB,
return _libssh2_error(session, LIBSSH2_ERROR_ZLIB,
"Excessive growth in decompression phase");
}
newout = LIBSSH2_REALLOC(session, out, out_maxlen);
if (!newout) {
LIBSSH2_FREE(session, out);
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to expand compress/"
"decompression buffer");
}
@ -237,7 +237,7 @@ comp_method_zlib_comp(LIBSSH2_SESSION * session,
if (out_maxlen >= (int) payload_limit) {
LIBSSH2_FREE(session, out);
return libssh2_error(session, LIBSSH2_ERROR_ZLIB,
return _libssh2_error(session, LIBSSH2_ERROR_ZLIB,
"Excessive growth in decompression "
"phase");
}
@ -252,7 +252,7 @@ comp_method_zlib_comp(LIBSSH2_SESSION * session,
newout = LIBSSH2_REALLOC(session, out, out_maxlen);
if (!newout) {
LIBSSH2_FREE(session, out);
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to expand final compress/"
"decompress buffer");
}
@ -267,7 +267,7 @@ comp_method_zlib_comp(LIBSSH2_SESSION * session,
}
if (status != Z_OK) {
LIBSSH2_FREE(session, out);
return libssh2_error(session, LIBSSH2_ERROR_ZLIB,
return _libssh2_error(session, LIBSSH2_ERROR_ZLIB,
"compress/decompression failure");
}
}

View File

@ -324,7 +324,7 @@ hostkey_method_ssh_dss_sig_verify(LIBSSH2_SESSION * session,
sig += 15;
sig_len -= 15;
if (sig_len != 40) {
return libssh2_error(session, LIBSSH2_ERROR_PROTO,
return _libssh2_error(session, LIBSSH2_ERROR_PROTO,
"Invalid DSS signature length");
}
return _libssh2_dsa_sha1_verify(dsactx, sig, m, m_len);

View File

@ -80,7 +80,7 @@ libssh2_keepalive_send (LIBSSH2_SESSION *session,
/* Silently ignore PACKET_EAGAIN here: if the write buffer is
already full, sending another keepalive is not useful. */
if (rc && rc != PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send keepalive message");
return rc;
}

View File

@ -44,7 +44,7 @@
/* TODO: Switch this to an inline and handle alloc() failures */
/* Helper macro called from kex_method_diffie_hellman_group1_sha1_key_exchange */
#define LIBSSH2_KEX_METHOD_DIFFIE_HELLMAN_SHA1_HASH(value, reqlen, version) \
{ \
{ \
libssh2_sha1_ctx hash; \
unsigned long len = 0; \
if (!(value)) { \
@ -67,7 +67,7 @@
libssh2_sha1_final(hash, (value) + len); \
len += SHA_DIGEST_LENGTH; \
} \
}
}
/*
* diffie_hellman_sha1
@ -118,7 +118,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
exchange_state->e_packet =
LIBSSH2_ALLOC(session, exchange_state->e_packet_len);
if (!exchange_state->e_packet) {
ret = libssh2_error(session, LIBSSH2_ERROR_ALLOC,
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Out of memory error");
goto clean_exit;
}
@ -145,7 +145,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
if (rc == PACKET_EAGAIN) {
return rc;
} else if (rc) {
ret = libssh2_error(session, rc,
ret = _libssh2_error(session, rc,
"Unable to send KEX init message");
goto clean_exit;
}
@ -190,7 +190,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
return rc;
}
if (rc) {
ret = libssh2_error(session, LIBSSH2_ERROR_TIMEOUT,
ret = _libssh2_error(session, LIBSSH2_ERROR_TIMEOUT,
"Timed out waiting for KEX reply");
goto clean_exit;
}
@ -203,7 +203,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
session->server_hostkey =
LIBSSH2_ALLOC(session, session->server_hostkey_len);
if (!session->server_hostkey) {
ret = libssh2_error(session, LIBSSH2_ERROR_ALLOC,
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for a copy "
"of the host key");
goto clean_exit;
@ -260,7 +260,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
if (session->hostkey->init(session, session->server_hostkey,
session->server_hostkey_len,
&session->server_hostkey_abstract)) {
ret = libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT,
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT,
"Unable to initialize hostkey importer");
goto clean_exit;
}
@ -287,7 +287,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
exchange_state->k_value =
LIBSSH2_ALLOC(session, exchange_state->k_value_len);
if (!exchange_state->k_value) {
ret = libssh2_error(session, LIBSSH2_ERROR_ALLOC,
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate buffer for K");
goto clean_exit;
}
@ -398,7 +398,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
sig_verify(session, exchange_state->h_sig,
exchange_state->h_sig_len, exchange_state->h_sig_comp,
20, &session->server_hostkey_abstract)) {
ret = libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_SIGN,
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_SIGN,
"Unable to verify hostkey signature");
goto clean_exit;
}
@ -414,7 +414,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
if (rc == PACKET_EAGAIN) {
return rc;
} else if (rc) {
ret = libssh2_error(session, rc, "Unable to send NEWKEYS message");
ret = _libssh2_error(session, rc, "Unable to send NEWKEYS message");
goto clean_exit;
}
@ -429,7 +429,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
if (rc == PACKET_EAGAIN) {
return rc;
} else if (rc) {
ret = libssh2_error(session, rc, "Timed out waiting for NEWKEYS");
ret = _libssh2_error(session, rc, "Timed out waiting for NEWKEYS");
goto clean_exit;
}
/* The first key exchange has been performed,
@ -444,7 +444,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
if (!session->session_id) {
session->session_id = LIBSSH2_ALLOC(session, SHA_DIGEST_LENGTH);
if (!session->session_id) {
ret = libssh2_error(session, LIBSSH2_ERROR_ALLOC,
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate buffer for SHA digest");
goto clean_exit;
}
@ -815,7 +815,7 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
if (rc == PACKET_EAGAIN) {
return rc;
} else if (rc) {
ret = libssh2_error(session, rc,
ret = _libssh2_error(session, rc,
"Unable to send Group Exchange Request");
goto dh_gex_clean_exit;
}
@ -830,7 +830,7 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
if (rc == PACKET_EAGAIN) {
return rc;
} else if (rc) {
ret = libssh2_error(session, rc,
ret = _libssh2_error(session, rc,
"Timeout waiting for GEX_GROUP reply");
goto dh_gex_clean_exit;
}
@ -891,7 +891,7 @@ static const LIBSSH2_KEX_METHOD kex_method_diffie_helman_group14_sha1 = {
};
static const LIBSSH2_KEX_METHOD
kex_method_diffie_helman_group_exchange_sha1 = {
kex_method_diffie_helman_group_exchange_sha1 = {
"diffie-hellman-group-exchange-sha1",
kex_method_diffie_hellman_group_exchange_sha1_key_exchange,
LIBSSH2_KEX_METHOD_FLAG_REQ_SIGN_HOSTKEY,
@ -1026,7 +1026,7 @@ static int kexinit(LIBSSH2_SESSION * session)
s = data = LIBSSH2_ALLOC(session, data_len);
if (!data) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory");
}
@ -1115,7 +1115,7 @@ static int kexinit(LIBSSH2_SESSION * session)
else if (rc) {
LIBSSH2_FREE(session, data);
session->kexinit_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to send KEXINIT packet to remote host");
}
@ -1634,7 +1634,7 @@ static int kex_agree_methods(LIBSSH2_SESSION * session, unsigned char *data,
* Exchange keys
* Returns 0 on success, non-zero on failure
*
* Returns some errors without libssh2_error()
* Returns some errors without _libssh2_error()
*/
int
libssh2_kex_exchange(LIBSSH2_SESSION * session, int reexchange,
@ -1736,7 +1736,7 @@ libssh2_kex_exchange(LIBSSH2_SESSION * session, int reexchange,
session->state &= ~LIBSSH2_STATE_KEX_ACTIVE;
return retcode;
} else if (retcode) {
rc = libssh2_error(session, LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE,
rc = _libssh2_error(session, LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE,
"Unrecoverable error exchanging keys");
}
}
@ -1825,13 +1825,13 @@ libssh2_session_method_pref(LIBSSH2_SESSION * session, int method_type,
break;
default:
return libssh2_error(session, LIBSSH2_ERROR_INVAL,
return _libssh2_error(session, LIBSSH2_ERROR_INVAL,
"Invalid parameter specified for method_type");
}
s = newprefs = LIBSSH2_ALLOC(session, prefs_len + 1);
if (!newprefs) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Error allocated space for method preferences");
}
memcpy(s, prefs, prefs_len + 1);
@ -1858,7 +1858,7 @@ libssh2_session_method_pref(LIBSSH2_SESSION * session, int method_type,
if (strlen(newprefs) == 0) {
LIBSSH2_FREE(session, newprefs);
return libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"The requested method(s) are not currently "
"supported");
}

View File

@ -88,7 +88,7 @@ libssh2_knownhost_init(LIBSSH2_SESSION *session)
LIBSSH2_ALLOC(session, sizeof(struct _LIBSSH2_KNOWNHOSTS));
if(!knh) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for known-hosts "
"collection");
return NULL;
@ -137,13 +137,13 @@ knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
unsigned int ptrlen;
if(!entry)
return libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for known host "
"entry");
/* make sure we have a key type set */
if(!(typemask & LIBSSH2_KNOWNHOST_KEY_MASK)) {
rc = libssh2_error(hosts->session, LIBSSH2_ERROR_INVAL,
rc = _libssh2_error(hosts->session, LIBSSH2_ERROR_INVAL,
"No key type set");
goto error;
}
@ -157,7 +157,7 @@ knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
case LIBSSH2_KNOWNHOST_TYPE_CUSTOM:
entry->name = LIBSSH2_ALLOC(hosts->session, hostlen+1);
if(!entry->name) {
rc = libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
rc = _libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for host name");
goto error;
}
@ -179,7 +179,7 @@ knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
entry->salt_len = ptrlen;
break;
default:
rc = libssh2_error(hosts->session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
rc = _libssh2_error(hosts->session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Unknown host name type");
goto error;
}
@ -190,7 +190,7 @@ knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
keylen = strlen(key);
entry->key = LIBSSH2_ALLOC(hosts->session, keylen+1);
if(!entry->key) {
rc = libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
rc = _libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for key");
goto error;
}
@ -202,7 +202,7 @@ knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
size_t nlen = _libssh2_base64_encode(hosts->session, key, keylen,
&ptr);
if(!nlen) {
rc = libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
rc = _libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"base64-encoded key");
goto error;
@ -214,7 +214,7 @@ knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
if (comment) {
entry->comment = LIBSSH2_ALLOC(hosts->session, commentlen+1);
if(!entry->comment) {
rc = libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
rc = _libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for comment");
goto error;
}
@ -347,7 +347,7 @@ libssh2_knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
size_t nlen = _libssh2_base64_encode(hosts->session, key, keylen,
&keyalloc);
if(!nlen) {
libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for base64-encoded "
"key");
return LIBSSH2_KNOWNHOST_CHECK_FAILURE;
@ -440,7 +440,7 @@ libssh2_knownhost_del(LIBSSH2_KNOWNHOSTS *hosts,
/* check that this was retrieved the right way or get out */
if(!entry || (entry->magic != KNOWNHOST_MAGIC))
return libssh2_error(hosts->session, LIBSSH2_ERROR_INVAL,
return _libssh2_error(hosts->session, LIBSSH2_ERROR_INVAL,
"Invalid host information");
/* get the internal node pointer */
@ -542,7 +542,7 @@ static int hostline(LIBSSH2_KNOWNHOSTS *hosts,
const char *hash = NULL;
size_t saltlen = p - salt;
if(saltlen >= (sizeof(saltbuf)-1)) /* weird length */
return libssh2_error(hosts->session,
return _libssh2_error(hosts->session,
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Failed to parse known_hosts line "
"(unexpectedly long salt)");
@ -565,7 +565,7 @@ static int hostline(LIBSSH2_KNOWNHOSTS *hosts,
if((keylen < 20) ||
(seplen >= sizeof(hostbuf)-1) ||
(hostlen >= sizeof(hostbuf)-1))
return libssh2_error(hosts->session,
return _libssh2_error(hosts->session,
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Failed to parse known_hosts line "
"(unexpected length)");
@ -589,7 +589,7 @@ static int hostline(LIBSSH2_KNOWNHOSTS *hosts,
type |= LIBSSH2_KNOWNHOST_KEY_SSHRSA;
else
/* unknown key type */
return libssh2_error(hosts->session,
return _libssh2_error(hosts->session,
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Unknown key type");
@ -628,7 +628,7 @@ static int hostline(LIBSSH2_KNOWNHOSTS *hosts,
break;
default: /* unknown key format */
return libssh2_error(hosts->session,
return _libssh2_error(hosts->session,
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Unknown key format");
}
@ -699,7 +699,7 @@ libssh2_knownhost_readline(LIBSSH2_KNOWNHOSTS *hosts,
int rc;
if(type != LIBSSH2_KNOWNHOST_FILE_OPENSSH)
return libssh2_error(hosts->session,
return _libssh2_error(hosts->session,
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Unsupported type of known-host information "
"store");
@ -734,7 +734,7 @@ libssh2_knownhost_readline(LIBSSH2_KNOWNHOSTS *hosts,
}
if(!*cp || !len) /* illegal line */
return libssh2_error(hosts->session,
return _libssh2_error(hosts->session,
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Failed to parse known_hosts line");
@ -777,7 +777,7 @@ libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts,
char buf[2048];
if(type != LIBSSH2_KNOWNHOST_FILE_OPENSSH)
return libssh2_error(hosts->session,
return _libssh2_error(hosts->session,
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Unsupported type of known-host information "
"store");
@ -792,7 +792,7 @@ libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts,
fclose(file);
}
else
return libssh2_error(hosts->session, LIBSSH2_ERROR_FILE,
return _libssh2_error(hosts->session, LIBSSH2_ERROR_FILE,
"Failed to open file");
return num;
@ -830,7 +830,7 @@ knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
/* we only support this single file type for now, bail out on all other
attempts */
if(type != LIBSSH2_KNOWNHOST_FILE_OPENSSH)
return libssh2_error(hosts->session,
return _libssh2_error(hosts->session,
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Unsupported type of known-host information "
"store");
@ -852,7 +852,7 @@ knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
nlen = _libssh2_base64_encode(hosts->session, node->name,
node->name_len, &namealloc);
if(!nlen)
return libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"base64-encoded host name");
@ -861,7 +861,7 @@ knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
&saltalloc);
if(!nlen) {
free(namealloc);
return libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(hosts->session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"base64-encoded salt");
}
@ -878,7 +878,7 @@ knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
sprintf(buf, "|1|%s|%s%s %s\n", saltalloc, namealloc,
keytype, node->key);
else
rc = libssh2_error(hosts->session, LIBSSH2_ERROR_BUFFER_TOO_SMALL,
rc = _libssh2_error(hosts->session, LIBSSH2_ERROR_BUFFER_TOO_SMALL,
"Known-host write buffer too small");
free(namealloc);
@ -896,7 +896,7 @@ knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
else
sprintf(buf, "%s%s %s\n", node->name, keytype, node->key);
else
rc = libssh2_error(hosts->session, LIBSSH2_ERROR_BUFFER_TOO_SMALL,
rc = _libssh2_error(hosts->session, LIBSSH2_ERROR_BUFFER_TOO_SMALL,
"Known-host write buffer too small");
}
@ -924,7 +924,7 @@ libssh2_knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
struct known_host *node;
if(known->magic != KNOWNHOST_MAGIC)
return libssh2_error(hosts->session, LIBSSH2_ERROR_INVAL,
return _libssh2_error(hosts->session, LIBSSH2_ERROR_INVAL,
"Invalid host information");
node = known->node;
@ -949,14 +949,14 @@ libssh2_knownhost_writefile(LIBSSH2_KNOWNHOSTS *hosts,
/* we only support this single file type for now, bail out on all other
attempts */
if(type != LIBSSH2_KNOWNHOST_FILE_OPENSSH)
return libssh2_error(hosts->session,
return _libssh2_error(hosts->session,
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
"Unsupported type of known-host information "
"store");
file = fopen(filename, "w");
if(!file)
return libssh2_error(hosts->session, LIBSSH2_ERROR_FILE,
return _libssh2_error(hosts->session, LIBSSH2_ERROR_FILE,
"Failed to open file");
for(node = _libssh2_list_first(&hosts->head);
@ -972,7 +972,7 @@ libssh2_knownhost_writefile(LIBSSH2_KNOWNHOSTS *hosts,
nwrote = fwrite(buffer, 1, wrote, file);
if(nwrote != wrote) {
/* failed to write the whole thing, bail out */
rc = libssh2_error(hosts->session, LIBSSH2_ERROR_FILE,
rc = _libssh2_error(hosts->session, LIBSSH2_ERROR_FILE,
"Write failed");
break;
}

View File

@ -1041,8 +1041,6 @@ _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...)
#endif
#endif
int libssh2_error(LIBSSH2_SESSION* session, int errcode, const char* errmsg);
#define LIBSSH2_SOCKET_UNKNOWN 1
#define LIBSSH2_SOCKET_CONNECTED 0
#define LIBSSH2_SOCKET_DISCONNECTED -1

View File

@ -49,7 +49,7 @@
#include <errno.h>
int libssh2_error(LIBSSH2_SESSION* session, int errcode, const char* errmsg)
int _libssh2_error(LIBSSH2_SESSION* session, int errcode, const char* errmsg)
{
session->err_msg = errmsg;
session->err_code = errcode;
@ -201,7 +201,7 @@ libssh2_base64_decode(LIBSSH2_SESSION *session, char **data,
*data = LIBSSH2_ALLOC(session, (3 * src_len / 4) + 1);
d = (unsigned char *) *data;
if (!d) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for base64 decoding");
}
@ -230,7 +230,7 @@ libssh2_base64_decode(LIBSSH2_SESSION *session, char **data,
/* Invalid -- We have a byte which belongs exclusively to a partial
octet */
LIBSSH2_FREE(session, *data);
return libssh2_error(session, LIBSSH2_ERROR_INVAL,
return _libssh2_error(session, LIBSSH2_ERROR_INVAL,
"Invalid data (byte belonging to partial octet)");
}

View File

@ -1,6 +1,6 @@
#ifndef __LIBSSH2_MISC_H
#define __LIBSSH2_MISC_H
/* Copyright (c) 2009 by Daniel Stenberg
/* Copyright (c) 2009-2010 by Daniel Stenberg
*
* All rights reserved.
*
@ -49,6 +49,8 @@ struct list_node {
struct list_head *head;
};
int _libssh2_error(LIBSSH2_SESSION* session, int errcode, const char* errmsg);
void _libssh2_list_init(struct list_head *head);
/* add a node last in the list */

View File

@ -140,7 +140,7 @@ packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data,
channel = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_CHANNEL));
if (!channel) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a channel for "
"new connection");
failure_code = 4; /* SSH_OPEN_RESOURCE_SHORTAGE */
@ -158,7 +158,7 @@ packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data,
channel_type_len +
1);
if (!channel->channel_type) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a channel for new"
" connection");
LIBSSH2_FREE(session, channel);
@ -213,7 +213,7 @@ packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data,
return rc;
else if (rc) {
listen_state->state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to send channel "
"open confirmation");
}
@ -253,7 +253,7 @@ packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data,
return rc;
} else if (rc) {
listen_state->state = libssh2_NB_state_idle;
return libssh2_error(session, rc, "Unable to send open failure");
return _libssh2_error(session, rc, "Unable to send open failure");
}
listen_state->state = libssh2_NB_state_idle;
@ -306,7 +306,7 @@ packet_x11_open(LIBSSH2_SESSION * session, unsigned char *data,
if (x11open_state->state == libssh2_NB_state_allocated) {
channel = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_CHANNEL));
if (!channel) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a channel for new connection");
failure_code = 4; /* SSH_OPEN_RESOURCE_SHORTAGE */
goto x11_exit;
@ -319,7 +319,7 @@ packet_x11_open(LIBSSH2_SESSION * session, unsigned char *data,
channel->channel_type_len +
1);
if (!channel->channel_type) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a channel for new connection");
LIBSSH2_FREE(session, channel);
failure_code = 4; /* SSH_OPEN_RESOURCE_SHORTAGE */
@ -367,7 +367,7 @@ packet_x11_open(LIBSSH2_SESSION * session, unsigned char *data,
return rc;
} else if (rc) {
x11open_state->state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send channel open "
"confirmation");
}
@ -407,7 +407,7 @@ packet_x11_open(LIBSSH2_SESSION * session, unsigned char *data,
return rc;
} else if (rc) {
x11open_state->state = libssh2_NB_state_idle;
return libssh2_error(session, rc, "Unable to send open failure");
return _libssh2_error(session, rc, "Unable to send open failure");
}
x11open_state->state = libssh2_NB_state_idle;
return 0;
@ -459,7 +459,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
"", 0);
}
LIBSSH2_FREE(session, data);
return libssh2_error(session, LIBSSH2_ERROR_INVALID_MAC,
return _libssh2_error(session, LIBSSH2_ERROR_INVALID_MAC,
"Invalid MAC received");
}
}
@ -529,7 +529,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
LIBSSH2_FREE(session, data);
session->socket_state = LIBSSH2_SOCKET_DISCONNECTED;
session->packAdd_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_DISCONNECT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_DISCONNECT,
"socket disconnect");
}
break;
@ -628,7 +628,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
_libssh2_channel_locate(session, _libssh2_ntohu32(data + 1));
if (!session->packAdd_channel) {
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_UNKNOWN,
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_UNKNOWN,
"Packet received for unknown channel, ignoring");
LIBSSH2_FREE(session, data);
session->packAdd_state = libssh2_NB_state_idle;
@ -682,7 +682,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
* Spec says we MAY ignore bytes sent beyond
* packet_size
*/
libssh2_error(session,
_libssh2_error(session,
LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED,
"Packet contains more data than we offered"
" to receive, truncating");
@ -695,7 +695,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
* Spec says we MAY ignore bytes sent beyond
* window_size
*/
libssh2_error(session,
_libssh2_error(session,
LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED,
"The current receive window is full,"
" data ignored");
@ -708,7 +708,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
if ((datalen - session->packAdd_data_head) >
session->packAdd_channel->remote.window_size) {
libssh2_error(session,
_libssh2_error(session,
LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED,
"Remote sent more data than current "
"window allows, truncating");

View File

@ -118,7 +118,7 @@ publickey_status_error(const LIBSSH2_PUBLICKEY *pkey,
msg = publickey_status_codes[status].name;
}
libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL, msg);
_libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL, msg);
}
/*
@ -140,7 +140,7 @@ publickey_packet_receive(LIBSSH2_PUBLICKEY * pkey,
if (rc == PACKET_EAGAIN) {
return rc;
} else if (rc != 4) {
return libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
"Invalid response from publickey subsystem");
}
@ -148,7 +148,7 @@ publickey_packet_receive(LIBSSH2_PUBLICKEY * pkey,
pkey->receive_packet =
LIBSSH2_ALLOC(session, pkey->receive_packet_len);
if (!pkey->receive_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate publickey response "
"buffer");
}
@ -165,7 +165,7 @@ publickey_packet_receive(LIBSSH2_PUBLICKEY * pkey,
LIBSSH2_FREE(session, pkey->receive_packet);
pkey->receive_packet = NULL;
pkey->receive_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for publickey subsystem "
"response packet");
}
@ -233,7 +233,7 @@ publickey_response_success(LIBSSH2_PUBLICKEY * pkey)
if (rc == PACKET_EAGAIN) {
return rc;
} else if (rc) {
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for response from "
"publickey subsystem");
}
@ -241,7 +241,7 @@ publickey_response_success(LIBSSH2_PUBLICKEY * pkey)
s = data;
if ((response = publickey_response_id(&s, data_len)) < 0) {
LIBSSH2_FREE(session, data);
return libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
"Invalid publickey subsystem response code");
}
@ -261,7 +261,7 @@ publickey_response_success(LIBSSH2_PUBLICKEY * pkey)
}
default:
/* Unknown/Unexpected */
libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
"Unexpected publickey subsystem response, ignoring");
LIBSSH2_FREE(session, data);
data = NULL;
@ -312,13 +312,13 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
&& (libssh2_session_last_errno(session) ==
LIBSSH2_ERROR_EAGAIN)) {
/* The error state is already set, so leave it */
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block to startup channel");
return NULL;
} else if (!session->pkeyInit_channel
&& (libssh2_session_last_errno(session) !=
LIBSSH2_ERROR_EAGAIN)) {
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Unable to startup channel");
goto err_exit;
}
@ -333,11 +333,11 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
sizeof("subsystem") - 1,
"publickey", strlen("publickey"));
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block starting publickey subsystem");
return NULL;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Unable to request publickey subsystem");
goto err_exit;
}
@ -349,7 +349,7 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
rc = libssh2_channel_handle_extended_data2(session->pkeyInit_channel,
LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block starting publickey subsystem");
return NULL;
}
@ -357,7 +357,7 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
session->pkeyInit_pkey =
LIBSSH2_ALLOC(session, sizeof(LIBSSH2_PUBLICKEY));
if (!session->pkeyInit_pkey) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a new publickey structure");
goto err_exit;
}
@ -386,11 +386,11 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
rc = _libssh2_channel_write(session->pkeyInit_channel, 0,
(char *) buffer, (s - buffer));
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending publickey version packet");
return NULL;
} else if ((s - buffer) != rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send publickey version packet");
goto err_exit;
}
@ -404,12 +404,12 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
&session->pkeyInit_data,
&session->pkeyInit_data_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting for response from "
"publickey subsystem");
return NULL;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for response from "
"publickey subsystem");
goto err_exit;
@ -418,7 +418,7 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
s = session->pkeyInit_data;
if ((response =
publickey_response_id(&s, session->pkeyInit_data_len)) < 0) {
libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
"Invalid publickey subsystem response code");
goto err_exit;
}
@ -443,7 +443,7 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
if (s >
session->pkeyInit_data + session->pkeyInit_data_len) {
libssh2_error(session,
_libssh2_error(session,
LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
"Malformed publickey subsystem packet");
goto err_exit;
@ -475,7 +475,7 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
default:
/* Unknown/Unexpected */
libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
"Unexpected publickey subsystem response, "
"ignoring");
LIBSSH2_FREE(session, session->pkeyInit_data);
@ -490,7 +490,7 @@ libssh2_publickey_init(LIBSSH2_SESSION * session)
if (session->pkeyInit_channel) {
rc = libssh2_channel_close(session->pkeyInit_channel);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block closing channel");
return NULL;
}
@ -555,7 +555,7 @@ libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY * pkey, const unsigned char *name,
pkey->add_packet = LIBSSH2_ALLOC(session, packet_len);
if (!pkey->add_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"publickey \"add\" packet");
}
@ -625,7 +625,7 @@ libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY * pkey, const unsigned char *name,
} else if ((pkey->add_s - pkey->add_packet) != rc) {
LIBSSH2_FREE(session, pkey->add_packet);
pkey->add_packet = NULL;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send publickey add packet");
}
LIBSSH2_FREE(session, pkey->add_packet);
@ -663,7 +663,7 @@ libssh2_publickey_remove_ex(LIBSSH2_PUBLICKEY * pkey,
pkey->remove_packet = LIBSSH2_ALLOC(session, packet_len);
if (!pkey->remove_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"publickey \"remove\" packet");
}
@ -700,7 +700,7 @@ libssh2_publickey_remove_ex(LIBSSH2_PUBLICKEY * pkey,
LIBSSH2_FREE(session, pkey->remove_packet);
pkey->remove_packet = NULL;
pkey->remove_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send publickey remove packet");
}
LIBSSH2_FREE(session, pkey->remove_packet);
@ -760,7 +760,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys,
return rc;
} else if ((pkey->listFetch_s - pkey->listFetch_buffer) != rc) {
pkey->listFetch_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send publickey list packet");
}
@ -773,7 +773,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys,
if (rc == PACKET_EAGAIN) {
return rc;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for response from "
"publickey subsystem");
goto err_exit;
@ -783,7 +783,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys,
if ((response =
publickey_response_id(&pkey->listFetch_s,
pkey->listFetch_data_len)) < 0) {
libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
"Invalid publickey subsystem response code");
goto err_exit;
}
@ -808,7 +808,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys,
if (pkey->listFetch_s >
pkey->listFetch_data + pkey->listFetch_data_len) {
libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
"Malformed publickey subsystem packet");
goto err_exit;
}
@ -836,7 +836,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys,
(max_keys +
1) * sizeof(libssh2_publickey_list));
if (!newlist) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"publickey list");
goto err_exit;
@ -854,7 +854,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys,
LIBSSH2_ALLOC(session,
sizeof(libssh2_publickey_attribute));
if (!list[keys].attrs) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"publickey attributes");
goto err_exit;
@ -896,7 +896,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys,
list[keys].num_attrs *
sizeof(libssh2_publickey_attribute));
if (!list[keys].attrs) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"publickey attributes");
goto err_exit;
@ -926,7 +926,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys,
break;
default:
/* Unknown/Unexpected */
libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
"Unexpected publickey subsystem response, ignoring");
LIBSSH2_FREE(session, pkey->listFetch_data);
pkey->listFetch_data = NULL;

View File

@ -285,7 +285,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a command buffer for "
"SCP session");
return NULL;
@ -323,7 +323,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block starting up channel");
}
return NULL;
@ -339,7 +339,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block requesting SCP startup");
return NULL;
} else if (rc) {
@ -361,7 +361,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending initial wakeup");
return NULL;
} else if (rc != 1) {
@ -386,12 +386,12 @@ 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,
_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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Timed out waiting for SCP response");
goto scp_recv_error;
}
@ -402,7 +402,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid data in SCP response, missing Time data");
session->scpRecv_err_len =
@ -426,11 +426,11 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Unknown error" );
}
else
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"SCP protocol error");
/* TODO: for debugging purposes, the
@ -458,7 +458,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid data in SCP response");
goto scp_recv_error;
}
@ -470,7 +470,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Unterminated response from SCP server");
goto scp_recv_error;
}
@ -493,7 +493,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, "
"too short" );
goto scp_recv_error;
@ -504,7 +504,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, "
"malformed mtime");
goto scp_recv_error;
@ -515,14 +515,14 @@ 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,
_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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, malformed mtime.usec");
goto scp_recv_error;
}
@ -532,7 +532,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, too short or malformed");
goto scp_recv_error;
}
@ -542,7 +542,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, invalid atime");
goto scp_recv_error;
}
@ -558,7 +558,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting to send SCP ACK");
return NULL;
} else if (rc != 1) {
@ -595,19 +595,19 @@ 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,
_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,
_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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server");
goto scp_recv_error;
}
@ -625,7 +625,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid data in SCP response");
goto scp_recv_error;
}
@ -637,7 +637,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Unterminated response from SCP server");
goto scp_recv_error;
}
@ -661,7 +661,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, too short");
goto scp_recv_error;
}
@ -671,7 +671,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, malformed mode");
goto scp_recv_error;
}
@ -681,7 +681,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, invalid mode");
goto scp_recv_error;
}
@ -689,7 +689,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
s = strchr(p, ' ');
if (!s || ((s - p) <= 0)) {
/* No spaces or space in the wrong spot */
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, too short or malformed");
goto scp_recv_error;
}
@ -699,7 +699,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server, invalid size");
goto scp_recv_error;
}
@ -715,7 +715,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending SCP ACK");
return NULL;
} else if (rc != 1) {
@ -789,7 +789,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a command buffer for scp session");
return NULL;
}
@ -826,7 +826,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
session->scpSend_state = libssh2_NB_state_idle;
}
else {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block starting up channel");
}
return NULL;
@ -842,7 +842,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block requesting SCP startup");
return NULL;
}
@ -851,7 +851,7 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Unknown error while getting error string");
goto scp_send_error;
}
@ -866,11 +866,11 @@ 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,
_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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid ACK response from remote");
goto scp_send_error;
}
@ -895,11 +895,11 @@ 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,
_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,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send time data for SCP file");
goto scp_send_error;
}
@ -912,11 +912,11 @@ 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,
_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,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid ACK response from remote");
goto scp_send_error;
}
@ -953,11 +953,11 @@ 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,
_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,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send core file data for SCP file");
goto scp_send_error;
}
@ -970,11 +970,11 @@ 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,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting for response");
return NULL;
} else if (rc <= 0) {
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid ACK response from remote");
goto scp_send_error;
} else if (session->scpSend_response[0] != 0) {
@ -982,7 +982,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
* Set this as the default error for here, if
* we are successful it will be replaced
*/
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid ACK response from remote");
session->scpSend_err_len =
@ -1007,7 +1007,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
session->scpSend_err_msg = NULL;
}
else
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"failed waiting for ACK");
goto scp_send_error;
}

View File

@ -163,7 +163,7 @@ banner_receive(LIBSSH2_SESSION * session)
session->remote.banner = LIBSSH2_ALLOC(session, banner_len + 1);
if (!session->remote.banner) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Error allocating space for remote banner");
}
memcpy(session->remote.banner, session->banner_TxRx_banner, banner_len);
@ -403,7 +403,7 @@ libssh2_banner_set(LIBSSH2_SESSION * session, const char *banner)
session->local.banner = LIBSSH2_ALLOC(session, banner_len + 3);
if (!session->local.banner) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for local banner");
}
@ -592,7 +592,7 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
"session_startup for socket %d", sock);
if (INVALID_SOCKET == sock) {
/* Did we forget something? */
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_NONE,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_NONE,
"Bad socket provided");
}
session->socket_fd = sock;
@ -611,7 +611,7 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
if (session->startup_state == libssh2_NB_state_created) {
rc = banner_send(session);
if (rc) {
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Failed sending banner");
}
session->startup_state = libssh2_NB_state_sent;
@ -620,7 +620,7 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
if (session->startup_state == libssh2_NB_state_sent) {
rc = banner_receive(session);
if (rc) {
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Failed getting banner");
}
@ -630,7 +630,7 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
if (session->startup_state == libssh2_NB_state_sent1) {
rc = libssh2_kex_exchange(session, 0, &session->startup_key_state);
if (rc) {
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to exchange encryption keys");
}
@ -655,7 +655,7 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
rc = _libssh2_transport_write(session, session->startup_service,
sizeof("ssh-userauth") + 5 - 1);
if (rc) {
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Unable to ask for ssh-userauth service");
}
@ -678,7 +678,7 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
session->startup_service_length)) {
LIBSSH2_FREE(session, session->startup_data);
session->startup_data = NULL;
return libssh2_error(session, LIBSSH2_ERROR_PROTO,
return _libssh2_error(session, LIBSSH2_ERROR_PROTO,
"Invalid response received from server");
}
LIBSSH2_FREE(session, session->startup_data);
@ -1004,7 +1004,7 @@ session_disconnect(LIBSSH2_SESSION *session, int reason,
LIBSSH2_ALLOC(session, session->disconnect_data_len);
if (!session->disconnect_data) {
session->disconnect_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"disconnect packet");
}
@ -1111,13 +1111,13 @@ libssh2_session_methods(LIBSSH2_SESSION * session, int method_type)
return "";
default:
libssh2_error(session, LIBSSH2_ERROR_INVAL,
_libssh2_error(session, LIBSSH2_ERROR_INVAL,
"Invalid parameter specified for method_type");
return NULL;
}
if (!method) {
libssh2_error(session, LIBSSH2_ERROR_METHOD_NONE,
_libssh2_error(session, LIBSSH2_ERROR_METHOD_NONE,
"No method negotiated");
return NULL;
}
@ -1358,7 +1358,7 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout)
default:
if (session)
libssh2_error(session, LIBSSH2_ERROR_INVALID_POLL_TYPE,
_libssh2_error(session, LIBSSH2_ERROR_INVALID_POLL_TYPE,
"Invalid descriptor passed to libssh2_poll()");
return -1;
}
@ -1405,7 +1405,7 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout)
default:
if (session)
libssh2_error(session, LIBSSH2_ERROR_INVALID_POLL_TYPE,
_libssh2_error(session, LIBSSH2_ERROR_INVALID_POLL_TYPE,
"Invalid descriptor passed to libssh2_poll()");
return -1;
}

View File

@ -122,7 +122,7 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
(int) data[0], data_len);
packet = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_PACKET));
if (!packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate datablock for SFTP packet");
}
memset(packet, 0, sizeof(LIBSSH2_PACKET));
@ -174,7 +174,7 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
/* TODO: this is stupid since we can in fact get 1-3 bytes in a
legitimate working case as well if the connection happens to be
super slow or something */
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Read part of packet");
}
@ -182,13 +182,13 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
_libssh2_debug(session, LIBSSH2_TRACE_SFTP,
"Data begin - Packet Length: %lu", packet_len);
if (packet_len > LIBSSH2_SFTP_PACKET_MAXLEN) {
return libssh2_error(session, LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED,
return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED,
"SFTP packet too large");
}
packet = LIBSSH2_ALLOC(session, packet_len);
if (!packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate SFTP packet");
}
@ -216,7 +216,7 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
}
else if (bytes_received < 0) {
LIBSSH2_FREE(session, packet);
return libssh2_error(session, bytes_received,
return _libssh2_error(session, bytes_received,
"Receive error waiting for SFTP packet");
}
packet_received += bytes_received;
@ -554,11 +554,11 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
LIBSSH2_CHANNEL_PACKET_DEFAULT, NULL, 0);
if (!session->sftpInit_channel) {
if (libssh2_session_last_errno(session) == LIBSSH2_ERROR_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block starting up channel");
}
else {
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Unable to startup channel");
session->sftpInit_state = libssh2_NB_state_idle;
}
@ -574,11 +574,11 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
sizeof("subsystem") - 1, "sftp",
strlen("sftp"));
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block to request SFTP subsystem");
return NULL;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Unable to request SFTP subsystem");
goto sftp_init_error;
}
@ -590,7 +590,7 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
rc = _libssh2_channel_extended_data(session->sftpInit_channel,
LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block requesting handle extended data");
return NULL;
}
@ -599,7 +599,7 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
session->sftpInit_sftp =
LIBSSH2_ALLOC(session, sizeof(LIBSSH2_SFTP));
if (!sftp_handle) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate a new SFTP structure");
goto sftp_init_error;
}
@ -626,12 +626,12 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
session->sftpInit_sent,
9 - session->sftpInit_sent);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending SSH_FXP_INIT");
return NULL;
}
else if(rc < 0) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send SSH_FXP_INIT");
goto sftp_init_error;
}
@ -650,16 +650,16 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
rc = sftp_packet_require(sftp_handle, SSH_FXP_VERSION,
0, &data, &data_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting for response from SFTP subsystem");
return NULL;
} else if (rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for response from SFTP subsystem");
goto sftp_init_error;
}
if (data_len < 5) {
libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Invalid SSH_FXP_VERSION response");
goto sftp_init_error;
}
@ -841,7 +841,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
s = sftp->open_packet = LIBSSH2_ALLOC(session, sftp->open_packet_len);
if (!sftp->open_packet) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_OPEN or "
"FXP_OPENDIR packet");
return NULL;
@ -881,7 +881,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
rc = _libssh2_channel_write(channel, 0, (char *) sftp->open_packet,
sftp->open_packet_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block sending FXP_OPEN or FXP_OPENDIR command");
return NULL;
}
@ -889,7 +889,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
/* TODO: partial writes should be fine too and is not a sign of
an error when in non-blocking mode! */
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_OPEN or FXP_OPENDIR command");
LIBSSH2_FREE(session, sftp->open_packet);
sftp->open_packet = NULL;
@ -907,12 +907,12 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
sftp->open_request_id, &data,
&data_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting for status message");
return NULL;
}
else if (rc) {
libssh2_error(session, rc, "Timeout waiting for status message");
_libssh2_error(session, rc, "Timeout waiting for status message");
sftp->open_state = libssh2_NB_state_idle;
return NULL;
}
@ -945,7 +945,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
}
if(badness) {
libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
_libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Failed opening remote file");
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "got FXP_STATUS %d",
sftp->last_errno);
@ -956,7 +956,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
fp = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_SFTP_HANDLE));
if (!fp) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate new SFTP handle structure");
LIBSSH2_FREE(session, data);
return NULL;
@ -1101,7 +1101,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
non-blocking mode! */
sftp->read_packet = NULL;
sftp->read_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"_libssh2_channel_write() failed");
}
sftp->read_packet = packet;
@ -1115,12 +1115,12 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
sftp_packet_requirev(sftp, 2, read_responses,
request_id, &data, &data_len);
if (retcode == PACKET_EAGAIN) {
return libssh2_error(session, retcode,
return _libssh2_error(session, retcode,
"Would block waiting for status message");
} else if (retcode) {
sftp->read_packet = NULL;
sftp->read_state = libssh2_NB_state_idle;
return libssh2_error(session, retcode,
return _libssh2_error(session, retcode,
"Timeout waiting for status message");
}
@ -1141,7 +1141,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
return total_read;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
@ -1260,7 +1260,7 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
s = sftp->readdir_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->readdir_packet)
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"FXP_READDIR packet");
@ -1291,7 +1291,7 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
LIBSSH2_FREE(session, sftp->readdir_packet);
sftp->readdir_packet = NULL;
sftp->readdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"_libssh2_channel_write() failed");
}
@ -1308,7 +1308,7 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
return retcode;
else if (retcode) {
sftp->readdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
@ -1322,7 +1322,7 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
else {
sftp->last_errno = retcode;
sftp->readdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@ -1395,7 +1395,7 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
(unsigned long) count);
s = sftp->write_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->write_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_WRITE");
}
_libssh2_htonu32(s, packet_len - 4);
@ -1444,7 +1444,7 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
}
else if (rc) {
sftp->write_state = libssh2_NB_state_idle;
return libssh2_error(session, rc,
return _libssh2_error(session, rc,
"Timeout waiting for status message");
}
@ -1459,7 +1459,7 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
}
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
@ -1502,7 +1502,7 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
setstat ? "set-stat" : "stat");
s = sftp->fstat_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->fstat_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"FSTAT/FSETSTAT packet");
}
@ -1533,7 +1533,7 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
LIBSSH2_FREE(session, sftp->fstat_packet);
sftp->fstat_packet = NULL;
sftp->fstat_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
(setstat ? "Unable to send FXP_FSETSTAT"
: "Unable to send FXP_FSTAT command"));
}
@ -1550,7 +1550,7 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
return rc;
} else if (rc) {
sftp->fstat_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
@ -1565,7 +1565,7 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@ -1650,7 +1650,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Closing handle");
s = handle->close_packet = LIBSSH2_ALLOC(session, packet_len);
if (!handle->close_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_CLOSE "
"packet");
}
@ -1678,7 +1678,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
LIBSSH2_FREE(session, handle->close_packet);
handle->close_packet = NULL;
handle->close_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_CLOSE command");
}
LIBSSH2_FREE(session, handle->close_packet);
@ -1695,7 +1695,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
return rc;
} else if (rc) {
handle->close_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
@ -1708,7 +1708,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
if (retcode != LIBSSH2_FX_OK) {
sftp->last_errno = retcode;
handle->close_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
@ -1759,7 +1759,7 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Unlinking %s", filename);
s = sftp->unlink_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->unlink_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_REMOVE "
"packet");
}
@ -1787,7 +1787,7 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
LIBSSH2_FREE(session, sftp->unlink_packet);
sftp->unlink_packet = NULL;
sftp->unlink_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_REMOVE command");
}
LIBSSH2_FREE(session, sftp->unlink_packet);
@ -1804,7 +1804,7 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
}
else if (rc) {
sftp->unlink_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
@ -1817,7 +1817,7 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@ -1858,7 +1858,7 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
int rc;
if (sftp->version < 2) {
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Server does not support RENAME");
}
@ -1868,7 +1868,7 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
sftp->rename_s = sftp->rename_packet =
LIBSSH2_ALLOC(session, packet_len);
if (!sftp->rename_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_RENAME "
"packet");
}
@ -1905,7 +1905,7 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
LIBSSH2_FREE(session, sftp->rename_packet);
sftp->rename_packet = NULL;
sftp->rename_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_RENAME command");
}
LIBSSH2_FREE(session, sftp->rename_packet);
@ -1921,7 +1921,7 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
return rc;
} else if (rc) {
sftp->rename_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
@ -1940,18 +1940,18 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
break;
case LIBSSH2_FX_FILE_ALREADY_EXISTS:
retcode = libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
retcode = _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"File already exists and "
"SSH_FXP_RENAME_OVERWRITE not specified");
break;
case LIBSSH2_FX_OP_UNSUPPORTED:
retcode = libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
retcode = _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Operation Not Supported");
break;
default:
retcode = libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
retcode = _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
break;
}
@ -2000,7 +2000,7 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path,
"Creating directory %s with mode 0%lo", path, mode);
s = packet = LIBSSH2_ALLOC(session, packet_len);
if (!packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_MKDIR "
"packet");
}
@ -2034,7 +2034,7 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path,
if (packet_len != rc) {
LIBSSH2_FREE(session, packet);
sftp->mkdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"_libssh2_channel_write() failed");
}
LIBSSH2_FREE(session, packet);
@ -2048,7 +2048,7 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path,
return rc;
} else if (rc) {
sftp->mkdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
@ -2062,7 +2062,7 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@ -2102,7 +2102,7 @@ static int sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path,
path);
s = sftp->rmdir_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->rmdir_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_RMDIR "
"packet");
}
@ -2130,7 +2130,7 @@ static int sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path,
LIBSSH2_FREE(session, sftp->rmdir_packet);
sftp->rmdir_packet = NULL;
sftp->rmdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send FXP_RMDIR command");
}
LIBSSH2_FREE(session, sftp->rmdir_packet);
@ -2145,7 +2145,7 @@ static int sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path,
return rc;
} else if (rc) {
sftp->rmdir_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
@ -2158,7 +2158,7 @@ static int sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@ -2203,7 +2203,7 @@ static int sftp_stat(LIBSSH2_SFTP *sftp, const char *path,
LIBSSH2_SFTP_LSTAT ? "LStatting" : "Statting"), path);
s = sftp->stat_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->stat_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for FXP_*STAT "
"packet");
}
@ -2246,7 +2246,7 @@ static int sftp_stat(LIBSSH2_SFTP *sftp, const char *path,
LIBSSH2_FREE(session, sftp->stat_packet);
sftp->stat_packet = NULL;
sftp->stat_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send STAT/LSTAT/SETSTAT command");
}
LIBSSH2_FREE(session, sftp->stat_packet);
@ -2261,7 +2261,7 @@ static int sftp_stat(LIBSSH2_SFTP *sftp, const char *path,
return rc;
} else if (rc) {
sftp->stat_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
@ -2276,7 +2276,7 @@ static int sftp_stat(LIBSSH2_SFTP *sftp, const char *path,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
@ -2322,14 +2322,14 @@ static int sftp_symlink(LIBSSH2_SFTP *sftp, const char *path,
int rc;
if ((sftp->version < 3) && (link_type != LIBSSH2_SFTP_REALPATH)) {
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Server does not support SYMLINK or READLINK");
}
if (sftp->symlink_state == libssh2_NB_state_idle) {
s = sftp->symlink_packet = LIBSSH2_ALLOC(session, packet_len);
if (!sftp->symlink_packet) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"SYMLINK/READLINK/REALPATH packet");
}
@ -2381,7 +2381,7 @@ static int sftp_symlink(LIBSSH2_SFTP *sftp, const char *path,
LIBSSH2_FREE(session, sftp->symlink_packet);
sftp->symlink_packet = NULL;
sftp->symlink_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send SYMLINK/READLINK command");
}
LIBSSH2_FREE(session, sftp->symlink_packet);
@ -2398,7 +2398,7 @@ static int sftp_symlink(LIBSSH2_SFTP *sftp, const char *path,
}
else if (rc) {
sftp->symlink_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_TIMEOUT,
"Timeout waiting for status message");
}
@ -2413,14 +2413,14 @@ static int sftp_symlink(LIBSSH2_SFTP *sftp, const char *path,
return 0;
} else {
sftp->last_errno = retcode;
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"SFTP Protocol Error");
}
}
if (_libssh2_ntohu32(data + 5) < 1) {
LIBSSH2_FREE(session, data);
return libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
"Invalid READLINK/REALPATH response, "
"no name entries");
}
@ -2459,5 +2459,3 @@ libssh2_sftp_last_error(LIBSSH2_SFTP *sftp)
{
return sftp->last_errno;
}

View File

@ -71,7 +71,8 @@ debugdump(LIBSSH2_SESSION * session,
used = snprintf(buffer, sizeof(buffer), "=> %s (%d bytes)\n",
desc, (int) size);
if (session->tracehandler)
(session->tracehandler)(session, session->tracehandler_context, buffer, used);
(session->tracehandler)(session, session->tracehandler_context,
buffer, used);
else
write(2 /* stderr */, buffer, used);
@ -106,7 +107,8 @@ debugdump(LIBSSH2_SESSION * session,
buffer[used] = 0;
if (session->tracehandler)
(session->tracehandler)(session, session->tracehandler_context, buffer, used);
(session->tracehandler)(session, session->tracehandler_context,
buffer, used);
else
write(2, buffer, used);
}
@ -274,7 +276,7 @@ fullpacket(LIBSSH2_SESSION * session, int encrypted /* 1 or 0 */ )
* This function reads the binary stream as specified in chapter 6 of RFC4253
* "The Secure Shell (SSH) Transport Layer Protocol"
*
* DOES NOT call libssh2_error() for ANY error case.
* DOES NOT call _libssh2_error() for ANY error case.
*/
int _libssh2_transport_read(LIBSSH2_SESSION * session)
{
@ -693,7 +695,7 @@ send_existing(LIBSSH2_SESSION * session, unsigned char *data,
* which is what all implementations should support at least as packet size.
* (RFC4253 section 6.1)
*
* This function DOES not call libssh2_error() on any errors.
* This function DOES not call _libssh2_error() on any errors.
*/
int
_libssh2_transport_write(LIBSSH2_SESSION * session, unsigned char *data,

View File

@ -78,7 +78,7 @@ static char *userauth_list(LIBSSH2_SESSION *session, const char *username,
s = session->userauth_list_data =
LIBSSH2_ALLOC(session, session->userauth_list_data_len);
if (!session->userauth_list_data) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for userauth_list");
return NULL;
}
@ -108,7 +108,7 @@ static char *userauth_list(LIBSSH2_SESSION *session, const char *username,
rc = _libssh2_transport_write(session, session->userauth_list_data,
session->userauth_list_data_len);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block requesting userauth list");
return NULL;
}
@ -117,7 +117,7 @@ static char *userauth_list(LIBSSH2_SESSION *session, const char *username,
session->userauth_list_data = NULL;
if (rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send userauth-none request");
session->userauth_list_state = libssh2_NB_state_idle;
return NULL;
@ -133,18 +133,18 @@ static char *userauth_list(LIBSSH2_SESSION *session, const char *username,
NULL, 0,
&session->userauth_list_packet_requirev_state);
if (rc == PACKET_EAGAIN) {
libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block requesting userauth list");
return NULL;
} else if (rc) {
libssh2_error(session, rc, "Failed getting response");
_libssh2_error(session, rc, "Failed getting response");
session->userauth_list_state = libssh2_NB_state_idle;
return NULL;
}
if (session->userauth_list_data[0] == SSH_MSG_USERAUTH_SUCCESS) {
/* Wow, who'dve thought... */
libssh2_error(session, LIBSSH2_ERROR_NONE, "No error");
_libssh2_error(session, LIBSSH2_ERROR_NONE, "No error");
LIBSSH2_FREE(session, session->userauth_list_data);
session->userauth_list_data = NULL;
session->state |= LIBSSH2_STATE_AUTHENTICATED;
@ -230,7 +230,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
s = session->userauth_pswd_data =
LIBSSH2_ALLOC(session, session->userauth_pswd_data_len);
if (!session->userauth_pswd_data) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"userauth-password request");
}
@ -269,7 +269,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
rc = _libssh2_transport_write(session, session->userauth_pswd_data,
session->userauth_pswd_data_len);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block writing password request");
}
@ -279,7 +279,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
if (rc) {
session->userauth_pswd_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send userauth-password request");
}
@ -299,11 +299,11 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
&session->
userauth_pswd_packet_requirev_state);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting");
} else if (rc) {
session->userauth_pswd_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_TIMEOUT,
return _libssh2_error(session, LIBSSH2_ERROR_TIMEOUT,
"Would block waiting");
}
@ -321,7 +321,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
LIBSSH2_FREE(session, session->userauth_pswd_data);
session->userauth_pswd_data = NULL;
session->userauth_pswd_state = libssh2_NB_state_idle;
return libssh2_error(session,
return _libssh2_error(session,
LIBSSH2_ERROR_AUTHENTICATION_FAILED,
"Authentication failed "
"(username/password)");
@ -354,7 +354,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
&session->userauth_pswd_newpw_len,
&session->abstract);
if (!session->userauth_pswd_newpw) {
return libssh2_error(session,
return _libssh2_error(session,
LIBSSH2_ERROR_PASSWORD_EXPIRED,
"Password expired, and "
"callback failed");
@ -372,7 +372,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
LIBSSH2_FREE(session,
session->userauth_pswd_newpw);
session->userauth_pswd_newpw = NULL;
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory "
"for userauth password "
"change request");
@ -418,7 +418,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
session->
userauth_pswd_data_len);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block waiting");
}
@ -429,7 +429,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
session->userauth_pswd_newpw = NULL;
if (rc) {
return libssh2_error(session,
return _libssh2_error(session,
LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send userauth "
"password-change request");
@ -445,7 +445,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
}
} else {
session->userauth_pswd_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_PASSWORD_EXPIRED,
return _libssh2_error(session, LIBSSH2_ERROR_PASSWORD_EXPIRED,
"Password Expired, and no callback "
"specified");
}
@ -457,7 +457,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username,
session->userauth_pswd_data = NULL;
session->userauth_pswd_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_AUTHENTICATION_FAILED,
return _libssh2_error(session, LIBSSH2_ERROR_AUTHENTICATION_FAILED,
"Authentication failed");
}
@ -509,7 +509,7 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
/* Read Public Key */
fd = fopen(pubkeyfile, "r");
if (!fd) {
return libssh2_error(session, LIBSSH2_ERROR_FILE,
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
"Unable to open public key file");
}
while (!feof(fd) && (c = fgetc(fd)) != '\r' && c != '\n')
@ -522,20 +522,20 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
if (pubkey_len <= 1) {
fclose(fd);
return libssh2_error(session, LIBSSH2_ERROR_FILE,
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
"Invalid data in public key file");
}
pubkey = LIBSSH2_ALLOC(session, pubkey_len);
if (!pubkey) {
fclose(fd);
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for public key data");
}
if (fread(pubkey, 1, pubkey_len, fd) != pubkey_len) {
LIBSSH2_FREE(session, pubkey);
fclose(fd);
return libssh2_error(session, LIBSSH2_ERROR_FILE,
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
"Unable to read public key from file");
}
fclose(fd);
@ -547,13 +547,13 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
if (!pubkey_len) {
LIBSSH2_FREE(session, pubkey);
return libssh2_error(session, LIBSSH2_ERROR_FILE,
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
"Missing public key data");
}
if ((sp1 = memchr(pubkey, ' ', pubkey_len)) == NULL) {
LIBSSH2_FREE(session, pubkey);
return libssh2_error(session, LIBSSH2_ERROR_FILE,
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
"Invalid public key data");
}
@ -567,7 +567,7 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
if (libssh2_base64_decode(session, (char **) &tmp, &tmp_len,
(char *) sp1, sp2 - sp1)) {
LIBSSH2_FREE(session, pubkey);
return libssh2_error(session, LIBSSH2_ERROR_FILE,
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
"Invalid key data, not base64 encoded");
}
@ -612,14 +612,14 @@ file_read_privatekey(LIBSSH2_SESSION * session,
hostkey_methods_avail++;
}
if (!*hostkey_method) {
return libssh2_error(session, LIBSSH2_ERROR_METHOD_NONE,
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NONE,
"No handler for specified private key");
}
if ((*hostkey_method)->
initPEM(session, privkeyfile, (unsigned char *) passphrase,
hostkey_abstract)) {
return libssh2_error(session, LIBSSH2_ERROR_FILE,
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
"Unable to initialize private key from file");
}
@ -700,7 +700,7 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
&pubkeydata, &pubkeydata_len,
publickey);
if(rc)
/* Note: file_read_publickey() calls libssh2_error() */
/* Note: file_read_publickey() calls _libssh2_error() */
return rc;
/*
@ -727,7 +727,7 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
LIBSSH2_FREE(session, session->userauth_host_method);
session->userauth_host_method = NULL;
LIBSSH2_FREE(session, pubkeydata);
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Out of memory");
}
@ -777,7 +777,7 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
session->userauth_host_method_len,
privatekey, passphrase);
if(rc) {
/* Note: file_read_privatekey() calls libssh2_error() */
/* Note: file_read_privatekey() calls _libssh2_error() */
LIBSSH2_FREE(session, session->userauth_host_method);
session->userauth_host_method = NULL;
LIBSSH2_FREE(session, session->userauth_host_packet);
@ -821,7 +821,7 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
session->userauth_host_packet = NULL;
LIBSSH2_FREE(session, session->userauth_host_method);
session->userauth_host_method = NULL;
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Failed allocating additional space for "
"userauth-hostbased packet");
}
@ -861,13 +861,13 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
session->userauth_host_s -
session->userauth_host_packet);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
}
else if (rc) {
LIBSSH2_FREE(session, session->userauth_host_packet);
session->userauth_host_packet = NULL;
session->userauth_host_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send userauth-hostbased request");
}
LIBSSH2_FREE(session, session->userauth_host_packet);
@ -886,12 +886,12 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
&session->
userauth_host_packet_requirev_state);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
}
session->userauth_host_state = libssh2_NB_state_idle;
if (rc) {
return libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
return _libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
"Auth failed");
}
@ -909,7 +909,7 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
/* This public key is not allowed for this user on this server */
LIBSSH2_FREE(session, session->userauth_host_data);
session->userauth_host_data = NULL;
return libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
return _libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
"Invalid signature for supplied public key, or bad "
"username/public key combination");
}
@ -971,7 +971,7 @@ userauth_publickey(LIBSSH2_SESSION *session,
session->userauth_pblc_method =
LIBSSH2_ALLOC(session, session->userauth_pblc_method_len);
if (!session->userauth_pblc_method) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for public key "
"data");
}
@ -1004,7 +1004,7 @@ userauth_publickey(LIBSSH2_SESSION *session,
if (!session->userauth_pblc_packet) {
LIBSSH2_FREE(session, session->userauth_pblc_method);
session->userauth_pblc_method = NULL;
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Out of memory");
}
@ -1050,14 +1050,14 @@ userauth_publickey(LIBSSH2_SESSION *session,
rc = _libssh2_transport_write(session, session->userauth_pblc_packet,
session->userauth_pblc_packet_len);
if (rc == PACKET_EAGAIN)
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
else if (rc) {
LIBSSH2_FREE(session, session->userauth_pblc_packet);
session->userauth_pblc_packet = NULL;
LIBSSH2_FREE(session, session->userauth_pblc_method);
session->userauth_pblc_method = NULL;
session->userauth_pblc_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send userauth-publickey request");
}
@ -1072,7 +1072,7 @@ userauth_publickey(LIBSSH2_SESSION *session,
&session->
userauth_pblc_packet_requirev_state);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
}
else if (rc) {
LIBSSH2_FREE(session, session->userauth_pblc_packet);
@ -1080,7 +1080,7 @@ userauth_publickey(LIBSSH2_SESSION *session,
LIBSSH2_FREE(session, session->userauth_pblc_method);
session->userauth_pblc_method = NULL;
session->userauth_pblc_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
return _libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
"Failed waiting");
}
@ -1111,7 +1111,7 @@ userauth_publickey(LIBSSH2_SESSION *session,
LIBSSH2_FREE(session, session->userauth_pblc_method);
session->userauth_pblc_method = NULL;
session->userauth_pblc_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_AUTHENTICATION_FAILED,
return _libssh2_error(session, LIBSSH2_ERROR_AUTHENTICATION_FAILED,
"Username/PublicKey combination invalid");
}
@ -1131,7 +1131,7 @@ userauth_publickey(LIBSSH2_SESSION *session,
s = buf = LIBSSH2_ALLOC(session, 4 + session->session_id_len
+ session->userauth_pblc_packet_len);
if (!buf) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"userauth-publickey signed data");
}
@ -1147,14 +1147,14 @@ userauth_publickey(LIBSSH2_SESSION *session,
rc = sign_callback(session, &sig, &sig_len, buf, s - buf, abstract);
LIBSSH2_FREE(session, buf);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
} else if (rc) {
LIBSSH2_FREE(session, session->userauth_pblc_method);
session->userauth_pblc_method = NULL;
LIBSSH2_FREE(session, session->userauth_pblc_packet);
session->userauth_pblc_packet = NULL;
session->userauth_pblc_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
return _libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
"Callback returned error");
}
@ -1177,7 +1177,7 @@ userauth_publickey(LIBSSH2_SESSION *session,
LIBSSH2_FREE(session, session->userauth_pblc_method);
session->userauth_pblc_method = NULL;
session->userauth_pblc_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Failed allocating additional space for "
"userauth-publickey packet");
}
@ -1218,12 +1218,12 @@ userauth_publickey(LIBSSH2_SESSION *session,
session->userauth_pblc_s -
session->userauth_pblc_packet);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
} else if (rc) {
LIBSSH2_FREE(session, session->userauth_pblc_packet);
session->userauth_pblc_packet = NULL;
session->userauth_pblc_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send userauth-publickey request");
}
LIBSSH2_FREE(session, session->userauth_pblc_packet);
@ -1240,11 +1240,11 @@ userauth_publickey(LIBSSH2_SESSION *session,
&session->userauth_pblc_data_len, 0, NULL, 0,
&session->userauth_pblc_packet_requirev_state);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block requesting userauth list");
} else if (rc) {
session->userauth_pblc_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
return _libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
"Failed waiting");
}
@ -1263,7 +1263,7 @@ userauth_publickey(LIBSSH2_SESSION *session,
LIBSSH2_FREE(session, session->userauth_pblc_data);
session->userauth_pblc_data = NULL;
session->userauth_pblc_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
return _libssh2_error(session, LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED,
"Invalid signature for supplied public key, or bad "
"username/public key combination");
}
@ -1399,7 +1399,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
session->userauth_kybd_data = s =
LIBSSH2_ALLOC(session, session->userauth_kybd_packet_len);
if (!s) {
return libssh2_error(session, LIBSSH2_ERROR_ALLOC,
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"keyboard-interactive authentication");
}
@ -1442,12 +1442,12 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
rc = _libssh2_transport_write(session, session->userauth_kybd_data,
session->userauth_kybd_packet_len);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN, "Would block");
} else if (rc) {
LIBSSH2_FREE(session, session->userauth_kybd_data);
session->userauth_kybd_data = NULL;
session->userauth_kybd_state = libssh2_NB_state_idle;
return libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send keyboard-interactive request");
}
LIBSSH2_FREE(session, session->userauth_kybd_data);
@ -1465,11 +1465,11 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
&session->
userauth_kybd_packet_requirev_state);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block");
} else if (rc) {
session->userauth_kybd_state = libssh2_NB_state_idle;
return libssh2_error(session,
return _libssh2_error(session,
LIBSSH2_ERROR_AUTHENTICATION_FAILED,
"Failed waiting");
}
@ -1490,7 +1490,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
LIBSSH2_FREE(session, session->userauth_kybd_data);
session->userauth_kybd_data = NULL;
session->userauth_kybd_state = libssh2_NB_state_idle;
return libssh2_error(session,
return _libssh2_error(session,
LIBSSH2_ERROR_AUTHENTICATION_FAILED,
"Authentication failed "
"(keyboard-interactive)");
@ -1506,7 +1506,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
session->userauth_kybd_auth_name =
LIBSSH2_ALLOC(session, session->userauth_kybd_auth_name_len);
if (!session->userauth_kybd_auth_name) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"keyboard-interactive 'name' request field");
goto cleanup;
@ -1522,7 +1522,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
LIBSSH2_ALLOC(session,
session->userauth_kybd_auth_instruction_len);
if (!session->userauth_kybd_auth_instruction) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"keyboard-interactive 'instruction' "
"request field");
@ -1547,7 +1547,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
sizeof(LIBSSH2_USERAUTH_KBDINT_PROMPT) *
session->userauth_kybd_num_prompts);
if (!session->userauth_kybd_prompts) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"keyboard-interactive prompts array");
goto cleanup;
@ -1561,7 +1561,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
sizeof(LIBSSH2_USERAUTH_KBDINT_RESPONSE) *
session->userauth_kybd_num_prompts);
if (!session->userauth_kybd_responses) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"keyboard-interactive responses array");
goto cleanup;
@ -1578,7 +1578,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
LIBSSH2_ALLOC(session,
session->userauth_kybd_prompts[i].length);
if (!session->userauth_kybd_prompts[i].text) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for "
"keyboard-interactive prompt message");
goto cleanup;
@ -1622,7 +1622,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
session->userauth_kybd_data = s =
LIBSSH2_ALLOC(session, session->userauth_kybd_packet_len);
if (!s) {
libssh2_error(session, LIBSSH2_ERROR_ALLOC,
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for keyboard-"
"interactive response packet");
goto cleanup;
@ -1648,11 +1648,11 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
rc = _libssh2_transport_write(session, session->userauth_kybd_data,
session->userauth_kybd_packet_len);
if (rc == PACKET_EAGAIN) {
return libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block");
}
if (rc) {
libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
"Unable to send userauth-keyboard-interactive"
" request");
goto cleanup;