mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
Use consistent return values for packet_translate().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@456 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -64,7 +64,7 @@ static int wait_auth_status(SSH_SESSION *session,int kbdint){
|
|||||||
while(cont){
|
while(cont){
|
||||||
if(packet_read(session))
|
if(packet_read(session))
|
||||||
break;
|
break;
|
||||||
if(packet_translate(session))
|
if(packet_translate(session) != SSH_OK)
|
||||||
break;
|
break;
|
||||||
switch(session->in_packet.type){
|
switch(session->in_packet.type){
|
||||||
case SSH2_MSG_USERAUTH_FAILURE:
|
case SSH2_MSG_USERAUTH_FAILURE:
|
||||||
|
|||||||
@@ -32,11 +32,11 @@
|
|||||||
#ifdef HAVE_SSH1
|
#ifdef HAVE_SSH1
|
||||||
static int wait_auth1_status(SSH_SESSION *session) {
|
static int wait_auth1_status(SSH_SESSION *session) {
|
||||||
/* wait for a packet */
|
/* wait for a packet */
|
||||||
if (packet_read(session)) {
|
if (packet_read(session) != SSH_OK) {
|
||||||
return SSH_AUTH_ERROR;
|
return SSH_AUTH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(packet_translate(session)) {
|
if(packet_translate(session) != SSH_OK) {
|
||||||
return SSH_AUTH_ERROR;
|
return SSH_AUTH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1223,7 +1223,8 @@ int channel_read(CHANNEL *channel, BUFFER *buffer, u32 bytes, int is_stderr) {
|
|||||||
break; /* return the resting bytes in buffer */
|
break; /* return the resting bytes in buffer */
|
||||||
if(buffer_get_rest_len(stdbuf)>=maxread) // stop reading when buffer is full enough
|
if(buffer_get_rest_len(stdbuf)>=maxread) // stop reading when buffer is full enough
|
||||||
break;
|
break;
|
||||||
if(packet_read(session)||packet_translate(session)){
|
if ((packet_read(session)) != SSH_OK ||
|
||||||
|
(packet_translate(session) != SSH_OK)) {
|
||||||
leave_function();
|
leave_function();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -373,24 +373,29 @@ int packet_read(SSH_SESSION *session) {
|
|||||||
return packet_read2(session);
|
return packet_read2(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
int packet_translate(SSH_SESSION *session){
|
int packet_translate(SSH_SESSION *session) {
|
||||||
enter_function();
|
enter_function();
|
||||||
memset(&session->in_packet,0,sizeof(PACKET));
|
|
||||||
if(!session->in_buffer){
|
memset(&session->in_packet, 0, sizeof(PACKET));
|
||||||
leave_function();
|
if(session->in_buffer == NULL) {
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ssh_log(session, SSH_LOG_RARE, "Final size %d",
|
|
||||||
buffer_get_rest_len(session->in_buffer));
|
|
||||||
if(!buffer_get_u8(session->in_buffer,&session->in_packet.type)){
|
|
||||||
ssh_set_error(session,SSH_FATAL,"Packet too short to read type");
|
|
||||||
leave_function();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ssh_log(session, SSH_LOG_RARE, "Type %hhd", session->in_packet.type);
|
|
||||||
session->in_packet.valid=1;
|
|
||||||
leave_function();
|
leave_function();
|
||||||
return 0;
|
return SSH_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssh_log(session, SSH_LOG_RARE, "Final size %d",
|
||||||
|
buffer_get_rest_len(session->in_buffer));
|
||||||
|
|
||||||
|
if(buffer_get_u8(session->in_buffer, &session->in_packet.type) == 0) {
|
||||||
|
ssh_set_error(session, SSH_FATAL, "Packet too short to read type");
|
||||||
|
leave_function();
|
||||||
|
return SSH_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssh_log(session, SSH_LOG_RARE, "Type %hhd", session->in_packet.type);
|
||||||
|
session->in_packet.valid = 1;
|
||||||
|
|
||||||
|
leave_function();
|
||||||
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the the bufferized output. If the session is blocking, or enforce_blocking
|
/* Write the the bufferized output. If the session is blocking, or enforce_blocking
|
||||||
@@ -585,7 +590,8 @@ static int packet_wait1(SSH_SESSION *session,int type,int blocking){
|
|||||||
enter_function();
|
enter_function();
|
||||||
ssh_log(session,SSH_LOG_PROTOCOL,"packet_wait1 waiting for %d",type);
|
ssh_log(session,SSH_LOG_PROTOCOL,"packet_wait1 waiting for %d",type);
|
||||||
while(1){
|
while(1){
|
||||||
if(packet_read1(session) || packet_translate(session)){
|
if ((packet_read1(session) != SSH_OK) ||
|
||||||
|
(packet_translate(session) != SSH_OK)) {
|
||||||
leave_function();
|
leave_function();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -637,7 +643,7 @@ static int packet_wait2(SSH_SESSION *session,int type,int blocking){
|
|||||||
leave_function();
|
leave_function();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if(packet_translate(session)){
|
if (packet_translate(session) != SSH_OK) {
|
||||||
leave_function();
|
leave_function();
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,7 +215,8 @@ int ssh_handle_packets(SSH_SESSION *session){
|
|||||||
return r; // error or no data available
|
return r; // error or no data available
|
||||||
}
|
}
|
||||||
/* if an exception happened, it will be trapped by packet_read() */
|
/* if an exception happened, it will be trapped by packet_read() */
|
||||||
if(packet_read(session)||packet_translate(session)){
|
if ((packet_read(session) != SSH_OK) ||
|
||||||
|
(packet_translate(session) != SSH_OK)) {
|
||||||
leave_function();
|
leave_function();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user