1
1

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
Этот коммит содержится в:
Andreas Schneider 2009-04-14 08:55:33 +00:00
родитель 640cf4cc93
Коммит 22b3122c6c
5 изменённых файлов: 32 добавлений и 24 удалений

@ -64,7 +64,7 @@ static int wait_auth_status(SSH_SESSION *session,int kbdint){
while(cont){
if(packet_read(session))
break;
if(packet_translate(session))
if(packet_translate(session) != SSH_OK)
break;
switch(session->in_packet.type){
case SSH2_MSG_USERAUTH_FAILURE:

@ -32,11 +32,11 @@
#ifdef HAVE_SSH1
static int wait_auth1_status(SSH_SESSION *session) {
/* wait for a packet */
if (packet_read(session)) {
if (packet_read(session) != SSH_OK) {
return SSH_AUTH_ERROR;
}
if(packet_translate(session)) {
if(packet_translate(session) != SSH_OK) {
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 */
if(buffer_get_rest_len(stdbuf)>=maxread) // stop reading when buffer is full enough
break;
if(packet_read(session)||packet_translate(session)){
if ((packet_read(session)) != SSH_OK ||
(packet_translate(session) != SSH_OK)) {
leave_function();
return -1;
}

@ -373,24 +373,29 @@ int packet_read(SSH_SESSION *session) {
return packet_read2(session);
}
int packet_translate(SSH_SESSION *session){
enter_function();
memset(&session->in_packet,0,sizeof(PACKET));
if(!session->in_buffer){
leave_function();
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;
int packet_translate(SSH_SESSION *session) {
enter_function();
memset(&session->in_packet, 0, sizeof(PACKET));
if(session->in_buffer == NULL) {
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
@ -585,7 +590,8 @@ static int packet_wait1(SSH_SESSION *session,int type,int blocking){
enter_function();
ssh_log(session,SSH_LOG_PROTOCOL,"packet_wait1 waiting for %d",type);
while(1){
if(packet_read1(session) || packet_translate(session)){
if ((packet_read1(session) != SSH_OK) ||
(packet_translate(session) != SSH_OK)) {
leave_function();
return -1;
}
@ -637,7 +643,7 @@ static int packet_wait2(SSH_SESSION *session,int type,int blocking){
leave_function();
return ret;
}
if(packet_translate(session)){
if (packet_translate(session) != SSH_OK) {
leave_function();
return SSH_ERROR;
}

@ -215,7 +215,8 @@ int ssh_handle_packets(SSH_SESSION *session){
return r; // error or no data available
}
/* 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();
return -1;
}