From 886ec331c9898de79c2edbb9c98e4946630a13b1 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Wed, 14 Feb 2007 14:43:34 +0000 Subject: [PATCH] Enlarged read buffer size. Fixed header comments. --- lib/silcsftp/sftp_client.c | 7 +++++-- lib/silcsftp/sftp_server.c | 4 ++-- lib/silcsftp/sftp_util.c | 5 +++-- lib/silcsftp/silcsftp.h | 13 +++++++------ 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/silcsftp/sftp_client.c b/lib/silcsftp/sftp_client.c index 3fb2ee02..0f6305af 100644 --- a/lib/silcsftp/sftp_client.c +++ b/lib/silcsftp/sftp_client.c @@ -313,6 +313,7 @@ static void silc_sftp_call_request(SilcSFTPClient sftp, break; default: + SILC_LOG_DEBUG(("Unknown request type %d", req->type)); break; } @@ -329,7 +330,7 @@ static void silc_sftp_client_io(SilcStream stream, SilcStreamStatus status, void *context) { SilcSFTPClient sftp = context; - unsigned char inbuf[30720]; + unsigned char inbuf[33792]; SilcBufferStruct packet; int ret; @@ -347,6 +348,8 @@ static void silc_sftp_client_io(SilcStream stream, SilcStreamStatus status, return; } + SILC_LOG_DEBUG(("Read %d bytes", ret)); + /* Now process the SFTP packet */ silc_buffer_set(&packet, inbuf, ret); silc_sftp_client_receive_process(context, &packet); @@ -455,7 +458,7 @@ void silc_sftp_client_receive_process(SilcSFTP context, SilcBuffer buffer) /* Parse the packet */ type = silc_sftp_packet_decode(buffer, &payload, &payload_len); - if (!type) + if (type <= 0) return; silc_buffer_set(&buf, payload, payload_len); diff --git a/lib/silcsftp/sftp_server.c b/lib/silcsftp/sftp_server.c index c78575aa..549751e8 100644 --- a/lib/silcsftp/sftp_server.c +++ b/lib/silcsftp/sftp_server.c @@ -90,7 +90,7 @@ static void silc_sftp_server_io(SilcStream stream, SilcStreamStatus status, void *context) { SilcSFTPServer sftp = context; - unsigned char inbuf[30720]; + unsigned char inbuf[33792]; SilcBufferStruct packet; int ret; @@ -427,7 +427,7 @@ static void silc_sftp_server_receive_process(SilcSFTP sftp, SilcBuffer buffer) /* Parse the packet */ type = silc_sftp_packet_decode(buffer, &payload, &payload_len); - if (!type) + if (type <= 0) return; silc_buffer_set(&buf, payload, payload_len); diff --git a/lib/silcsftp/sftp_util.c b/lib/silcsftp/sftp_util.c index 6aa40dbe..82618185 100644 --- a/lib/silcsftp/sftp_util.c +++ b/lib/silcsftp/sftp_util.c @@ -90,7 +90,8 @@ SilcBuffer silc_sftp_packet_encode_vp(SilcSFTPPacket packet, /* Decodes the SFTP packet data `packet' and return the SFTP packet type. The payload of the packet is returned to the `payload' pointer. Returns - 0 if error occurred during decoding. */ + 0 if error occurred during decoding and -1 if partial packet was + received. */ SilcSFTPPacket silc_sftp_packet_decode(SilcBuffer packet, unsigned char **payload, @@ -111,7 +112,7 @@ SilcSFTPPacket silc_sftp_packet_decode(SilcBuffer packet, return 0; if (len > (silc_buffer_len(packet) - 5)) - return 0; + return -1; silc_buffer_pull(packet, 5); ret = silc_buffer_unformat(packet, diff --git a/lib/silcsftp/silcsftp.h b/lib/silcsftp/silcsftp.h index c1aa5624..cf6711fe 100644 --- a/lib/silcsftp/silcsftp.h +++ b/lib/silcsftp/silcsftp.h @@ -426,8 +426,8 @@ SilcSFTP silc_sftp_client_start(SilcStream stream, * DESCRIPTION * * Shutdown's the SFTP client. The caller is responsible of closing - * the associated socket connection. The SFTP context is freed and is - * invalid after this function returns. + * the associated stream. The SFTP context is freed and is invalid after + * this function returns. * ***/ void silc_sftp_client_shutdown(SilcSFTP sftp); @@ -889,9 +889,9 @@ SilcSFTP silc_sftp_server_start(SilcStream stream, * * DESCRIPTION * - * Shutdown's the SFTP server. The caller is responsible of closing - * the associated socket connection. The SFTP context is freed and is - * invalid after this function returns. + * Shutdown the SFTP server. The caller is responsible of closing the + * associated stream. The SFTP context is freed and is invalid after + * this function returns. * ***/ void silc_sftp_server_shutdown(SilcSFTP sftp); @@ -943,7 +943,8 @@ typedef enum { * * This structure includes the monitor type specific data. The * application can check what the client has requested from this - * structure. + * structure. See the comments below what data is available for what + * monitor type. * * SOURCE */ -- 2.24.0