From: Pekka Riikonen Date: Mon, 9 Jun 2008 13:50:02 +0000 (+0300) Subject: Merge branch 'silc.1.1.branch' of silc repo X-Git-Tag: 1.2.beta4~12 X-Git-Url: http://git.silcnet.org/gitweb/?p=runtime.git;a=commitdiff_plain;h=afcd9ed820b767d8b6676a9156fa561b24ac2363;hp=2f90e9e57682d83c4ed07df77c1c9b898cbc5702 Merge branch 'silc.1.1.branch' of silc repo Conflicts: CHANGES Makefile.ad Makefile.defines_int.in README.PLUGIN TODO apps/Makefile.ad apps/autodist/CHANGES apps/autodist/autodist.in apps/autodist/doc/autodist.1.in apps/autodist/doc/autodist.texi apps/irssi/Makefile.am apps/irssi/configure.ad apps/irssi/configure.in apps/irssi/docs/Makefile.am apps/irssi/docs/help/Makefile.am.gen apps/irssi/docs/help/in/cmode.in apps/irssi/docs/help/in/cumode.in apps/irssi/docs/help/in/key.in apps/irssi/scripts/Makefile.am apps/irssi/scripts/examples/Makefile.am apps/irssi/src/Makefile.am apps/irssi/src/core/Makefile.am apps/irssi/src/core/modules-load.c apps/irssi/src/fe-common/silc/Makefile.am apps/irssi/src/fe-common/silc/fe-common-silc.c apps/irssi/src/fe-common/silc/fe-silc-messages.c apps/irssi/src/fe-common/silc/module-formats.c apps/irssi/src/fe-text/Makefile.am apps/irssi/src/perl/Makefile.am apps/irssi/src/silc/core/Makefile.am apps/irssi/src/silc/core/client_ops.c apps/irssi/src/silc/core/clientutil.c apps/irssi/src/silc/core/silc-core.c apps/irssi/src/silc/core/silc-servers.c apps/silcd/Makefile.am apps/silcd/command.c apps/silcd/command_reply.c apps/silcd/idlist.c apps/silcd/idlist.h apps/silcd/packet_receive.c apps/silcd/packet_send.c apps/silcd/server.c apps/silcd/server.h apps/silcd/server_backup.c apps/silcd/server_http.c apps/silcd/server_internal.h apps/silcd/server_query.c apps/silcd/server_query.h apps/silcd/server_util.c apps/silcd/server_util.h apps/silcd/serverconfig.c apps/silcd/serverconfig.h apps/silcd/serverid.c apps/silcd/silcd.c configure.ad distdir/autodist distdir/client distdir/common distdir/default distdir/post-dist distdir/pre-dist-client distdir/pre-dist-toolkit distdir/server distdir/toolkit doc/Makefile.ad doc/example_silcd.conf.in doc/examples/silcd.prv doc/examples/silcd.pub doc/silcalgs.conf doc/silcd.conf.yo includes/silc.h.in includes/silcversion.h.in lib/Makefile.ad lib/configure.ad lib/contrib/Makefile.ad lib/doc/command_reply_args.html lib/doc/notifyargs.html lib/doc/porting.html lib/doc/silcclient_using.html lib/silcapputil/silcapputil.c lib/silcapputil/silcidcache.c lib/silcapputil/silcidcache.h lib/silcasn1/silcasn1_decode.c lib/silcasn1/silcasn1_encode.c lib/silcclient/client.c lib/silcclient/client_connect.c lib/silcclient/client_entry.c lib/silcclient/client_entry.h lib/silcclient/client_keyagr.c lib/silcclient/client_notify.c lib/silcclient/client_register.c lib/silcclient/command.c lib/silcclient/command_reply.c lib/silcclient/silcclient.h lib/silcclient/silcclient_entry.h lib/silccore/DIRECTORY lib/silccore/README lib/silccore/silcargument.c lib/silccore/silcattrs.c lib/silccore/silcnotify.c lib/silccore/silcpacket.c lib/silccore/silcpacket.h lib/silccrypt/Makefile.ad lib/silccrypt/aes.c lib/silccrypt/aes_x86.asm lib/silccrypt/aes_x86_64.asm lib/silccrypt/ciphers.h lib/silccrypt/configure.ad lib/silccrypt/rijndael_internal.h lib/silccrypt/silccipher.c lib/silccrypt/silcpk.c lib/silccrypt/silcpkcs.c lib/silccrypt/silcpkcs1.c lib/silcmath/configure.ad lib/silcsftp/sftp_client.c lib/silcsftp/sftp_fs_memory.c lib/silcsim/Makefile.ad lib/silcske/silcconnauth.c lib/silcske/silcske.c lib/silcske/silcske.h lib/silcskr/silcskr.c lib/silcutil/silcatomic.h lib/silcutil/silcbuffer.h lib/silcutil/silcbuffmt.c lib/silcutil/silcdlist.h lib/silcutil/silcfsm.c lib/silcutil/silclog.c lib/silcutil/silcmime.c lib/silcutil/silcnet.h lib/silcutil/silcschedule.c lib/silcutil/silcschedule.h lib/silcutil/silcschedule_i.h lib/silcutil/silcsocketstream_i.h lib/silcutil/silcstack.h lib/silcutil/silctime.c lib/silcutil/silcutil.c lib/silcutil/stacktrace.c lib/silcutil/tests/test_silcschedule.c lib/silcutil/unix/silcunixnet.c lib/silcutil/unix/silcunixthread.c tutorial/mybot/Makefile tutorial/mybot/mybot.c win32/libsilc/libsilc.def win32/libsilcclient/libsilcclient.def --- diff --git a/CHANGES b/CHANGES index c5f1ab51..9128a66f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,185 @@ +Thu Mar 13 13:31:35 EET 2008 Pekka Riikonen + + * Fixed silcd crash in NEW_CLIENT packet handling when nickname + is not present in the packet. Affected files are + apps/silcd/packet_receive.c. + +Fri Feb 22 16:12:27 EET 2008 Pekka Riikonen + + * Fixed partial encryption in CTR mode in AES. Change does not + affect interoperability in SILC due to the way CTR is used in + SILC. But, fixed anyway. Affected files are + lib/silccrypt/aes.c and rijndael_internal.h. + +Tue Jan 8 09:41:57 EET 2008 Pekka Riikonen + + * Fixed printable fingerprint bufferoverlfow, RedHat bug 372021. + Affected file is lib/silcutil/silcutil.c. + +Sun Dec 30 14:00:46 EET 2007 Pekka Riikonen + + * Fixed unix signal delivery in SILC scheduler. Affected file + is lib/silcutil/unix/silcunixschedule.c. + +Sun Nov 18 16:43:04 CET 2007 Jochen Eisinger + + * Add -avoid-version and -rpath flags when compiling the plugin. + Affected file is apps/irssi/src/fe-common/silc/Makefile.in + +Thu Nov 15 18:03:53 EET 2007 Pekka Riikonen + + * Reprocess JOIN command synchronously after resolving channel + user list. Affected file is lib/silcclient/command_reply.c. + + * In JOIN command reply check if the channel key is already + saved. If it is we have received new key from server while + resolving user and must not save the old key. Affected file + is lib/silcclient/command_reply.c. + + * Remove all channel keys and hmacs after giving LEAVE command. + Affected file is lib/silcclient/command_reply.c. + +Tue Nov 13 18:24:56 EET 2007 Pekka Riikonen + + * Added missing channel unreferencing in CMODE, CUMODE, + TOPIC, INVITE, BAN and KICK command replies. Affected + file is lib/silcclient/command_reply.c. + +Sun Nov 11 23:04:54 EET 2007 Pekka Riikonen + + * Free stream data and abort ongoing protocols correctly + for primary router connections receiving end of stream. + Affected file is apps/silcd/server.c. + +Sun Nov 11 16:02:12 EET 2007 Pekka Riikonen + + * SILC Server 1.1 Beta4. + +Sun Nov 11 14:15:48 EET 2007 Pekka Riikonen + + * SILC Toolkit 1.1.5. + +Sun Nov 11 11:22:35 EET 2007 Pekka Riikonen + + * Fixed connection authentication with public keys to use + correct public key as responder. Affected file is + lib/silcske/silcconnauth.c. + + * Fixed public key authentication in server. Affected file is + apps/silcd/serverconfig.c. + + * Fixed OPER and SILCOPER public key authentication. Affected + file is apps/silcd/server.c. + + * Fixed prefer_passphrase_auth flag in server. Fixed + disconnection of unauthenticated connection. Affected file is + apps/silcd/server.c. + + * Fixed client resuming in server. Affected file is + apps/silcd/packet_receive.c. + + * Fixed IDENTIFY and WHOWAS command reply to correctly update + client entries (fixes a crash). Affected file is + apps/silcd/command_reply.c. + +Tue Nov 6 16:39:20 EET 2007 Pekka Riikonen + + * SILC Client 1.1.3. + +Mon Nov 5 23:07:58 EET 2007 Pekka Riikonen + + * Zero tail of CTR mode IV in IV Included mode. Change does + not cause compatibility issues. Affected file is + lib/silcske/silcske.c. + +Mon Nov 5 22:24:25 EET 2007 Pekka Riikonen + + * SILC Toolkit 1.1.4. + + * Fixed CTR mode rekey. Affected file is lib/silcske/silcske.c. + + * Rewrote the IV Included CTR mode encryption/decryption in + packet engine. Affected file is lib/silccore/silcpacket.c. + +Sun Nov 4 15:20:25 EET 2007 Pekka Riikonen + + * Removed module_path and module options from the server + config file format. Affected file is apps/silcd/serverconfig.c. + + * Fixed non-IPv6 compilation error. Affected file is + lib/silcutil/unix/silcunixnet.c. + +Sat Nov 3 23:23:38 EET 2007 Pekka Riikonen + + * Do not free packet engine before uninitializing scheduler. + Do not disconnct already disconnected streams. Affected + files are in apps/silcd/. + + * Fixed setting correct ID for re-encrypted channel messages + in router-to-router connections. Affected file is + apps/silcd/packet_send.c. + +Sun Sep 30 15:16:18 EEST 2007 Pekka Riikonen + + * Fixed channel private key deleting when deleting the channel. + Affected file is lib/silcclient/client_channel.c. + +Sun Sep 9 17:52:49 EEST 2007 Pekka Riikonen + + * SILC Toolkit 1.1.3. + + * Fixed possible buffer overflows from SILC Config code. + Patch from Jérémy Bobbio. Affected file is + lib/silcutil/silcconfig.c. + +Sun Aug 26 12:28:49 EEST 2007 Pekka Riikonen + + * Fixed TIMEOUT handling in user info resolving during JOINing, + fixes crash. Affected file is lib/silcclient/client_notify.c. + + * Fixed mandatory UN and HN SILC public key identifier checking + (both must be present). Affected file is + lib/silccrypt/silcpk.c. + +Tue Aug 7 20:56:06 EEST 2007 Pekka Riikonen + + * Fixed alignment issues with 64-bit CPUs. Affected files + are lib/silcutil/silcschedule.c and unix/silcunixschedule.c. + + * Added "There are now xx nick's" to "are xx nicks". Affected + file is apps/irssi/src/fe-common/silc/module-formats.c. + +Sat Aug 4 18:37:22 EEST 2007 Pekka Riikonen + + * Fixed USERS command user mode handling (integer overflow). + Affected file is lib/silcclient/command_reply.c. + +Thu Jul 19 21:08:49 EEST 2007 Pekka Riikonen + + * Fixed big-endian issues from aes implementation. Affected + files are lib/silccrypt/aes.c. + + * Fixed lib/silcutil/silcatomic.h compilation on IA64. Patch + from Jérémy Bobbio. + + * Fixed public key identifier parsing to check lengths + correctly. Affected file is lib/silccrypt/silcpk.c. + +Wed Jul 4 08:06:38 EEST 2007 Pekka Riikonen + + * SILC Toolkit 1.1.2. + + * SILC Client 1.1.2. + +Mon Jul 2 17:28:47 CEST 2007 Pekka Riikonen + + * In silc_client_free check that scheduler is allocated before + trying to free it. Affected file is lib/silcclient/client.c. + + * Fixed buffer overflow in NICK_CHANGE notify. The destination + buffer for old nickname was too small. Affected file is + lib/silclient/client_notify.c. + Sun Jul 1 19:15:15 EEST 2007 Pekka Riikonen * SILC Server 1.1 Beta1. @@ -61,7 +243,7 @@ Mon Jun 18 23:47:22 EEST 2007 Pekka Riikonen * Use SILC_VERIFY to assert that silc_rwlock_wrlock can be called only once per thread on Unix. Affected file is lib/silcutil/unix/silcunixthread.c. Added same for mutex - as well. Documented same on the API in + as well. Documented same on the API in lib/silcutil/silcmutex.h. * Fixed USERS command reply write-lock unlocking. Affected file @@ -84,7 +266,7 @@ Thu Jun 14 21:15:31 CEST 2007 Jochen Eisinger apps/irssi/src/core/modules-load.c * Don't delete hilight entry (because it's just a pointer, not a - copy). Affected file is + copy). Affected file is apps/irssi/src/fe-common/silc/fe-silc-messages.c Mon Jun 11 22:10:17 EEST 2007 Pekka Riikonen @@ -135,7 +317,7 @@ Thu Jun 7 21:25:31 EEST 2007 Pekka Riikonen Wed Jun 6 18:33:05 EEST 2007 Pekka Riikonen - * Added notify callback to silc_schedule_init which can be used to + * Added notify callback to silc_schedule_init which can be used to set a notify callback for scheduler which is called when task is added to scheduler or deleted from scheduler. Affected file is lib/silcutil/silcschedule.[ch]. @@ -144,7 +326,7 @@ Wed Jun 6 18:33:05 EEST 2007 Pekka Riikonen was very short. Affected file is lib/silcutil/silcschedule.c. * Rewrote the SILC scheduler handling in SILC Client to not poll - every few msecs but to use the new notify callback. Affected + every few msecs but to use the new notify callback. Affected file is apps/irssi/src/silc/core/silc-core.c. * Fixed SFTP client library read buffer size which was too small. @@ -320,7 +502,7 @@ Fri May 18 18:10:36 EEST 2007 Pekka Riikonen better. Affected file is lib/silccilent/client_entry.c. * Added "foo#2 appears as foo" support to SILC Client when user - leaves or quits and one formatted nickname remain. Affected file + leaves or quits and one formatted nickname remain. Affected file is apps/irssi/src/silc/core/client_ops.c. * Send SilcChannelEntry to application in SILC_NOTIFY_TYPE_SIGNOFF. @@ -382,7 +564,7 @@ Wed May 16 09:34:10 EEST 2007 Pekka Riikonen Tue May 15 23:55:41 EEST 2007 Pekka Riikonen * Added SILC_VERIFY macro which is equivalent to SILC_ASSERT - but is compiled always in. Affected file is + but is compiled always in. Affected file is lib/silcutil/silclog.h. * Use SILC_VERIFY in FSM macros instead of SILC_ASSERT which is @@ -461,7 +643,7 @@ Wed May 9 19:51:28 EEST 2007 Pekka Riikonen on WIN32. Affected files are lib/silcutil/silclog_i.h and silclog.c. - * Rewrote WIN32 SILC Scheduler. It now handles non-blocking file + * Rewrote WIN32 SILC Scheduler. It now handles non-blocking file descriptors and sockets better. Though, room for optimization remains. Affected file is lib/silcutil/win32/silcwin32schedule.c. diff --git a/distdir/post-dist b/distdir/post-dist index cf1f93bd..3f27c9e9 100644 --- a/distdir/post-dist +++ b/distdir/post-dist @@ -6,8 +6,8 @@ package=$3 distdir=$4 if test -f $distdir.tar.gz; then - sha1sum $distdir.tar.gz > $distdir.tar.gz.sha1 + sha512sum $distdir.tar.gz > $distdir.tar.gz.sum fi if test -f $distdir.tar.bz2; then - sha1sum $distdir.tar.bz2 > $distdir.tar.bz2.sha1 + sha512sum $distdir.tar.bz2 > $distdir.tar.bz2.sum fi diff --git a/lib/silcutil/silcbuffmt.c b/lib/silcutil/silcbuffmt.c index 838177d1..db798c40 100644 --- a/lib/silcutil/silcbuffmt.c +++ b/lib/silcutil/silcbuffmt.c @@ -781,7 +781,8 @@ int silc_buffer_sunformat_vp_i(SilcStack stack, SilcBuffer src, va_list ap, UNFORMAT_HAS_SPACE(src, len2); if (silc_likely(len2 && x)) { *x = silc_scalloc(stack, len2 + 1, sizeof(unsigned char)); - memcpy(*x, src->data, len2); + if (*x) + memcpy(*x, src->data, len2); } silc_buffer_pull(src, len2); break; @@ -969,7 +970,8 @@ int silc_buffer_sunformat_vp_i(SilcStack stack, SilcBuffer src, va_list ap, UNFORMAT_HAS_SPACE(src, len2); if (silc_likely(x && len2)) { *x = silc_scalloc(stack, len2 + 1, sizeof(unsigned char)); - memcpy(*x, src->data, len2); + if (*x) + memcpy(*x, src->data, len2); } silc_buffer_pull(src, len2); break; @@ -1007,7 +1009,8 @@ int silc_buffer_sunformat_vp_i(SilcStack stack, SilcBuffer src, va_list ap, UNFORMAT_HAS_SPACE(src, len2); if (silc_likely(x && len2)) { *x = silc_scalloc(stack, len2 + 1, sizeof(unsigned char)); - memcpy(*x, src->data, len2); + if (*x) + memcpy(*x, src->data, len2); } silc_buffer_pull(src, len2); break; @@ -1095,7 +1098,8 @@ int silc_buffer_sunformat_vp_i(SilcStack stack, SilcBuffer src, va_list ap, *len3 = len2; if (x && len2) { *x = silc_scalloc(stack, len2 + 1, sizeof(unsigned char)); - memcpy(*x, src->data, len2); + if (*x) + memcpy(*x, src->data, len2); } silc_buffer_pull(src, len2); break; @@ -1174,9 +1178,10 @@ int silc_buffer_sunformat_vp_i(SilcStack stack, SilcBuffer src, va_list ap, SILC_GET32_MSB(len2, src->data); silc_buffer_pull(src, 4); UNFORMAT_HAS_SPACE(src, len2); - silc_buffer_sformat(stack, x, - SILC_STR_DATA(src->data, len2), - SILC_STR_END); + if (silc_buffer_sformat(stack, x, + SILC_STR_DATA(src->data, len2), + SILC_STR_END) < 0) + goto fail; silc_buffer_pull(src, len2); } break; diff --git a/lib/silcutil/silcconfig.c b/lib/silcutil/silcconfig.c index 0568bd42..0a9a3464 100644 --- a/lib/silcutil/silcconfig.c +++ b/lib/silcutil/silcconfig.c @@ -26,6 +26,8 @@ #define SILC_CONFIG_DEBUG(fmt) #endif +#define BUF_SIZE 255 + /* this is the option struct and currently it is only used internally to * the module and other structs. */ typedef struct SilcConfigOptionStruct { @@ -111,11 +113,14 @@ static void my_skip_line(SilcConfigFile *file) * a separator is any non alphanumeric character nor "_" or "-" */ static char *my_next_token(SilcConfigFile *file, char *to) { + unsigned int count = 0; register char *o; my_trim_spaces(file); o = file->p; - while (isalnum((int)*o) || (*o == '_') || (*o == '-')) + while ((isalnum((int)*o) || (*o == '_') || (*o == '-')) && count < BUF_SIZE) { + count++; *to++ = *o++; + } *to = '\0'; file->p = o; return to; @@ -129,24 +134,30 @@ static char *my_get_string(SilcConfigFile *file, char *to) my_trim_spaces(file); o = file->p; if (*o == '"') { - char *quot = strchr(++o, '"'); - int len = quot - o; - if (!quot) { /* XXX FIXME: gotta do something here */ - printf("Bullshit, missing matching \""); - exit(1); + unsigned int count = 0; + char *d = to; + while (count < BUF_SIZE) { + o++; + if (*o == '"') { + break; + } + if (*o == '\\') { + o++; + } + count++; + *d++ = *o; } - if (len <= 0) - *to = '\0'; - else { - strncpy(to, o, len); - to[len] = '\0'; + if (count >= BUF_SIZE) { /* XXX FIXME: gotta do something here */ + fprintf(stderr, "Bullshit, missing matching \""); + exit(1); } + *d = '\0'; /* update stream pointer */ - file->p = quot + 1; - return to; + file->p = o + 1; + } else { + /* we don't need quote parsing, fall-back to token extractor */ + my_next_token(file, to); } - /* we don't need quote parsing, fall-back to token extractor */ - my_next_token(file, to); return to; } @@ -453,7 +464,7 @@ static int silc_config_main_internal(SilcConfigEntity ent) /* loop throught statements */ while (1) { - char buf[255]; + char buf[BUF_SIZE]; SilcConfigOption *thisopt; /* makes it pointing to the next interesting char */ diff --git a/lib/silcutil/silcfdstream.c b/lib/silcutil/silcfdstream.c index 5ba65ba9..f0032e8b 100644 --- a/lib/silcutil/silcfdstream.c +++ b/lib/silcutil/silcfdstream.c @@ -21,7 +21,7 @@ /************************** Types and definitions ***************************/ -#define SILC_IS_FD_STREAM(s) (s->ops == &silc_fd_stream_ops) +#define SILC_IS_FD_STREAM(s) (s && s->ops == &silc_fd_stream_ops) const SilcStreamOps silc_fd_stream_ops; diff --git a/lib/silcutil/silcsocketstream.c b/lib/silcutil/silcsocketstream.c index 7f61e518..8d3056ed 100644 --- a/lib/silcutil/silcsocketstream.c +++ b/lib/silcutil/silcsocketstream.c @@ -355,6 +355,7 @@ SilcBool silc_socket_stream_set_qos(SilcStream stream, !limit_sec && !limit_usec) { silc_schedule_task_del_by_context(socket_stream->schedule, socket_stream->qos); + silc_free(socket_stream->qos->buffer); silc_free(socket_stream->qos); socket_stream->qos = NULL; return TRUE; @@ -375,7 +376,8 @@ SilcBool silc_socket_stream_set_qos(SilcStream stream, socket_stream->qos->cur_rate = 0; socket_stream->qos->sock = socket_stream; - socket_stream->qos->buffer = silc_malloc(read_limit_bytes); + socket_stream->qos->buffer = silc_realloc(socket_stream->qos->buffer, + read_limit_bytes); if (!socket_stream->qos->buffer) return FALSE; diff --git a/lib/silcutil/silcsocketstream_i.h b/lib/silcutil/silcsocketstream_i.h index 894c4b1e..aa080ccc 100644 --- a/lib/silcutil/silcsocketstream_i.h +++ b/lib/silcutil/silcsocketstream_i.h @@ -55,8 +55,8 @@ struct SilcSocketStreamStruct { unsigned int connected : 1; /* UDP connected state */ }; -#define SILC_IS_SOCKET_STREAM(s) (s->ops == &silc_socket_stream_ops) -#define SILC_IS_SOCKET_STREAM_UDP(s) (s->ops == &silc_socket_udp_stream_ops) +#define SILC_IS_SOCKET_STREAM(s) (s && s->ops == &silc_socket_stream_ops) +#define SILC_IS_SOCKET_STREAM_UDP(s) (s && s->ops == &silc_socket_udp_stream_ops) extern const SilcStreamOps silc_socket_stream_ops; extern const SilcStreamOps silc_socket_udp_stream_ops; diff --git a/lib/silcutil/unix/silcunixnet.c b/lib/silcutil/unix/silcunixnet.c index f18af24e..c216ccca 100644 --- a/lib/silcutil/unix/silcunixnet.c +++ b/lib/silcutil/unix/silcunixnet.c @@ -855,6 +855,9 @@ SILC_FSM_STATE(silc_net_connect_st_finish) silc_async_free(conn->op); } + if (conn->sock && conn->status != SILC_NET_OK) + silc_net_close_connection(conn->sock); + return SILC_FSM_FINISH; } diff --git a/lib/silcutil/unix/silcunixschedule.c b/lib/silcutil/unix/silcunixschedule.c index 5626eef5..1543d16e 100644 --- a/lib/silcutil/unix/silcunixschedule.c +++ b/lib/silcutil/unix/silcunixschedule.c @@ -287,6 +287,7 @@ SilcBool silc_schedule_internal_schedule_fd(SilcSchedule schedule, SILC_LOG_DEBUG(("epoll_ctl (DEL): %s", strerror(errno))); return FALSE; } + task->scheduled = FALSE; return TRUE; } diff --git a/lib/silcutil/unix/silcunixsocketstream.c b/lib/silcutil/unix/silcunixsocketstream.c index 552fa611..35b0ceed 100644 --- a/lib/silcutil/unix/silcunixsocketstream.c +++ b/lib/silcutil/unix/silcunixsocketstream.c @@ -105,8 +105,9 @@ int silc_socket_stream_read(SilcStream stream, unsigned char *buf, /* If QoS was applied, return the data that was pending. */ if (sock->qos->applied && sock->qos->data_len) { memcpy(buf, qosbuf, sock->qos->data_len); + len = sock->qos->data_len; sock->qos->data_len = 0; - return sock->qos->data_len; + return len; } /* If we have active QoS data pending, return with no data */ @@ -115,7 +116,8 @@ int silc_socket_stream_read(SilcStream stream, unsigned char *buf, return -1; } - /* Read the data from the socket. Never read more than the max limit. */ + /* Read the data from the socket. The qosbuf size is always the max + read limit size. */ len = (buf_len < sock->qos->read_limit_bytes ? buf_len : sock->qos->read_limit_bytes); len = read(sock->sock, qosbuf, len);