aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-12-13 20:49:47 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2009-12-13 20:49:47 +0100
commit9780f22866461e1376ffc48853a7f0d8c6b2f7a2 (patch)
tree89d8346f625a7fe45d4b7436311702c5bc3e11ce
parent46b2b99f6330c97478d1fcbf85e1ce8ff6c5d6d3 (diff)
downloadlibssh-9780f22866461e1376ffc48853a7f0d8c6b2f7a2.tar.gz
libssh-9780f22866461e1376ffc48853a7f0d8c6b2f7a2.tar.xz
libssh-9780f22866461e1376ffc48853a7f0d8c6b2f7a2.zip
Made packet_wait issue warnings
-rw-r--r--include/libssh/packet.h1
-rw-r--r--libssh/auth.c3
-rw-r--r--libssh/channels.c15
-rw-r--r--libssh/packet.c80
4 files changed, 11 insertions, 88 deletions
diff --git a/include/libssh/packet.h b/include/libssh/packet.h
index 155f3040..84a09ea3 100644
--- a/include/libssh/packet.h
+++ b/include/libssh/packet.h
@@ -29,7 +29,6 @@ typedef struct packet_struct {
uint8_t type;
} PACKET;
-void packet_parse(ssh_session session);
int packet_send(ssh_session session);
int packet_read(ssh_session session);
diff --git a/libssh/auth.c b/libssh/auth.c
index 171f4b75..9349cc72 100644
--- a/libssh/auth.c
+++ b/libssh/auth.c
@@ -160,7 +160,8 @@ static int wait_auth_status(ssh_session session, int kbdint) {
break;
}
default:
- packet_parse(session);
+ //packet_parse(session);
+ //FIXME: broken
break;
}
}
diff --git a/libssh/channels.c b/libssh/channels.c
index afd17717..59290c62 100644
--- a/libssh/channels.c
+++ b/libssh/channels.c
@@ -1799,13 +1799,7 @@ int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count,
/* Stop reading when buffer is full enough */
break;
}
-
- if ((packet_read(session)) != SSH_OK ||
- (packet_translate(session) != SSH_OK)) {
- leave_function();
- return -1;
- }
- packet_parse(session);
+ ssh_handle_packets(session);
}
if(channel->local_window < WINDOWLIMIT) {
@@ -1911,12 +1905,7 @@ int channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr)
break;
}
- if ((packet_read(session)) != SSH_OK ||
- (packet_translate(session) != SSH_OK)) {
- leave_function();
- return -1;
- }
- packet_parse(session);
+ ssh_handle_packets(session);
}
if (channel->local_window < WINDOWLIMIT) {
diff --git a/libssh/packet.c b/libssh/packet.c
index 6a3e0aef..73c22789 100644
--- a/libssh/packet.c
+++ b/libssh/packet.c
@@ -918,10 +918,10 @@ int packet_send(ssh_session session) {
return packet_send2(session);
}
+#ifdef WITH_SSH1
void packet_parse(ssh_session session) {
uint8_t type = session->in_packet.type;
-#ifdef WITH_SSH1
if (session->version == 1) {
/* SSH-1 */
switch(type) {
@@ -946,31 +946,9 @@ void packet_parse(ssh_session session) {
}
return;
} else {
-#endif /* WITH_SSH1 */
- switch(type) {
- case SSH2_MSG_DISCONNECT:
- case SSH2_MSG_CHANNEL_WINDOW_ADJUST:
- case SSH2_MSG_CHANNEL_DATA:
- case SSH2_MSG_CHANNEL_EXTENDED_DATA:
- case SSH2_MSG_CHANNEL_REQUEST:
- case SSH2_MSG_CHANNEL_EOF:
- case SSH2_MSG_CHANNEL_CLOSE:
- case SSH2_MSG_IGNORE:
- case SSH2_MSG_DEBUG:
- ssh_packet_process(session,type);
- return;
- case SSH2_MSG_SERVICE_REQUEST:
- case SSH2_MSG_USERAUTH_REQUEST:
- case SSH2_MSG_CHANNEL_OPEN:
- message_handle(session,NULL,type,session->in_buffer);
- return;
- default:
- ssh_log(session, SSH_LOG_RARE, "Received unhandled packet %d", type);
- }
-#ifdef WITH_SSH1
}
-#endif
}
+#endif
#ifdef WITH_SSH1
static int packet_wait1(ssh_session session, int type, int blocking) {
@@ -1032,57 +1010,13 @@ static int packet_wait1(ssh_session session, int type, int blocking) {
static int packet_wait2(ssh_session session, int type, int blocking) {
int rc = SSH_ERROR;
-
+ (void) type;
+ (void) blocking;
enter_function();
- do {
- rc = packet_read2(session);
- if (rc != SSH_OK) {
- leave_function();
- return rc;
- }
- if (packet_translate(session) != SSH_OK) {
- leave_function();
- return SSH_ERROR;
- }
- switch (session->in_packet.type) {
- case SSH2_MSG_DISCONNECT:
- packet_parse(session);
- ssh_log(session, SSH_LOG_PACKET, "received disconnect packet");
- leave_function();
- return SSH_ERROR;
- case SSH2_MSG_CHANNEL_WINDOW_ADJUST:
- case SSH2_MSG_CHANNEL_DATA:
- case SSH2_MSG_CHANNEL_EXTENDED_DATA:
- case SSH2_MSG_CHANNEL_REQUEST:
- case SSH2_MSG_CHANNEL_EOF:
- case SSH2_MSG_CHANNEL_CLOSE:
- case SSH2_MSG_SERVICE_REQUEST:
- case SSH2_MSG_USERAUTH_REQUEST:
- case SSH2_MSG_CHANNEL_OPEN:
- packet_parse(session);
- break;
- case SSH2_MSG_IGNORE:
- case SSH2_MSG_DEBUG:
- break;
- default:
- if (type && (type != session->in_packet.type)) {
- ssh_set_error(session, SSH_FATAL,
- "packet_wait2(): Received a %d type packet, but expected a %d\n",
- session->in_packet.type, type);
- leave_function();
- return SSH_ERROR;
- }
- leave_function();
- return SSH_OK;
- }
- if (blocking == 0) {
- leave_function();
- return SSH_OK; //shouldn't it return SSH_AGAIN here ?
- }
- } while(1);
-
+ ssh_log(session,SSH_LOG_RARE,"packet_wait called. BAD!");
+ rc=ssh_handle_packets(session);
leave_function();
- return SSH_OK;
+ return rc;
}
int packet_wait(ssh_session session, int type, int block) {