Commit f77e61b4 authored by Kartik Mistry's avatar Kartik Mistry 🇮🇳

New upstream version 1.29.0

parent 2c1bb0bd
...@@ -20,6 +20,7 @@ Fredrik Fornwall ...@@ -20,6 +20,7 @@ Fredrik Fornwall
ITriskTI ITriskTI
Igor Khomyakov Igor Khomyakov
Jarda Snajdr Jarda Snajdr
Juan Francisco Cantero Hurtado
Kcchouette Kcchouette
Kurt Kartaltepe Kurt Kartaltepe
Mingye Wang Mingye Wang
......
commit 561d49d6e530eb4ea4499f5bd7ce80416ff79738 (HEAD, tag: release-1.27.1, origin/master, origin/HEAD, master) commit e12693c02787c9ec26175909a080f420be4ca85b (HEAD, tag: release-1.29.0, origin/master, origin/HEAD, master)
Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
AuthorDate: 2016-09-17 AuthorDate: 2016-11-15
Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
CommitDate: 2016-09-17 CommitDate: 2016-11-15
Bump up version number to 1.27.1 Update NEWS
commit 812136dd8b568bfe797744bcfcd496aaa2e1b714 commit 10e7830050abf8b104a30ff3c6c323bf02a0c0f2
Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
AuthorDate: 2016-09-17 AuthorDate: 2016-11-15
Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
CommitDate: 2016-09-17 CommitDate: 2016-11-15
Update NEWS Update third-party libraries
commit dd5a3b672c45b07bfb864acb2314f1dcc70b2421
Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
AuthorDate: 2016-11-15
Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
CommitDate: 2016-11-15
Bump up version number to 1.29.0
commit d289dc1108324ff5589ab103ef0863faaa3c5de1
Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
AuthorDate: 2016-11-09
Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
CommitDate: 2016-11-09
WinTLS: Fix busy loop on write error
commit b4010a52c8249fe46771004013e3d6a700c0d4f0
Merge: a9a60ce 2df30b1
Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
AuthorDate: 2016-11-03
Commit: GitHub <noreply@github.com>
CommitDate: 2016-11-03
Merge pull request #766 from aria2/support-1xx
Support 1xx non-final response
commit 2df30b144748dda434aa0002d636220e1f3aa87b
Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
AuthorDate: 2016-11-03
Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
CommitDate: 2016-11-03
Support 1xx non-final response
commit a9a60cef1bac42512940d77fd031c3b301629498
Merge: 90452ae fb380d4
Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
AuthorDate: 2016-11-02
Commit: GitHub <noreply@github.com>
CommitDate: 2016-11-02
Merge pull request #765 from aria2/update-wslay
Update wslay
commit fb380d40166a2c8cc2c04cf060104bc983e2984b
Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
AuthorDate: 2016-11-02
Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
CommitDate: 2016-11-02
Update wslay
commit cfaec39be1ae9ac2c9b6a02470791b46ef15d934 commit 90452ae11b51cb7c7e411a939f81f2d455bac59a
Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Author: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
AuthorDate: 2016-09-17 AuthorDate: 2016-10-26
Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> Commit: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
CommitDate: 2016-09-17 CommitDate: 2016-10-26
Add missing libssl_compat.h to SRCS Don't download piece which is filtered out (e.g., --select-file)
This commit fixes the bug that piece which is not requested by
--select-file is downloaded in multi-file WebSeeding.
...@@ -30,10 +30,10 @@ RUN apt-get update && \ ...@@ -30,10 +30,10 @@ RUN apt-get update && \
RUN curl -L -O https://gmplib.org/download/gmp/gmp-6.1.1.tar.lz && \ RUN curl -L -O https://gmplib.org/download/gmp/gmp-6.1.1.tar.lz && \
curl -L -O http://downloads.sourceforge.net/project/expat/expat/2.2.0/expat-2.2.0.tar.bz2 && \ curl -L -O http://downloads.sourceforge.net/project/expat/expat/2.2.0/expat-2.2.0.tar.bz2 && \
curl -L -O https://sqlite.org/2016/sqlite-autoconf-3140200.tar.gz && \ curl -L -O https://www.sqlite.org/2016/sqlite-autoconf-3150100.tar.gz && \
curl -L -O http://zlib.net/zlib-1.2.8.tar.xz && \ curl -L -O http://zlib.net/zlib-1.2.8.tar.xz && \
curl -L -O http://c-ares.haxx.se/download/c-ares-1.11.0.tar.gz && \ curl -L -O https://c-ares.haxx.se/download/c-ares-1.12.0.tar.gz && \
curl -L -O http://libssh2.org/download/libssh2-1.7.0.tar.gz curl -L -O http://libssh2.org/download/libssh2-1.8.0.tar.gz
RUN tar xf gmp-6.1.1.tar.lz && \ RUN tar xf gmp-6.1.1.tar.lz && \
cd gmp-6.1.1 && \ cd gmp-6.1.1 && \
...@@ -57,8 +57,8 @@ RUN tar xf expat-2.2.0.tar.bz2 && \ ...@@ -57,8 +57,8 @@ RUN tar xf expat-2.2.0.tar.bz2 && \
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` && \ --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` && \
make install make install
RUN tar xf sqlite-autoconf-3140200.tar.gz && \ RUN tar xf sqlite-autoconf-3150100.tar.gz && \
cd sqlite-autoconf-3140200 && \ cd sqlite-autoconf-3150100 && \
./configure \ ./configure \
--disable-shared \ --disable-shared \
--enable-static \ --enable-static \
...@@ -81,8 +81,8 @@ RUN tar xf zlib-1.2.8.tar.xz && \ ...@@ -81,8 +81,8 @@ RUN tar xf zlib-1.2.8.tar.xz && \
--static && \ --static && \
make install make install
RUN tar xf c-ares-1.11.0.tar.gz && \ RUN tar xf c-ares-1.12.0.tar.gz && \
cd c-ares-1.11.0 && \ cd c-ares-1.12.0 && \
./configure \ ./configure \
--disable-shared \ --disable-shared \
--enable-static \ --enable-static \
...@@ -93,8 +93,8 @@ RUN tar xf c-ares-1.11.0.tar.gz && \ ...@@ -93,8 +93,8 @@ RUN tar xf c-ares-1.11.0.tar.gz && \
LIBS="-lws2_32" && \ LIBS="-lws2_32" && \
make install make install
RUN tar xf libssh2-1.7.0.tar.gz && \ RUN tar xf libssh2-1.8.0.tar.gz && \
cd libssh2-1.7.0 && \ cd libssh2-1.8.0 && \
./configure \ ./configure \
--disable-shared \ --disable-shared \
--enable-static \ --enable-static \
......
aria2 1.27.1 aria2 1.29.0
============ ============
Release Note Release Note
------------ ------------
This release fixes the packaging bug that libssl_compat.h is missing This release fixes several bugs. See Changes below for detailed bug
in the tar balls. fixes. This release adds 1xx non-final response support. Wslay
library is updated to the latest revision.
Changes Changes
------- -------
* Add missing libssl_compat.h to SRCS * WinTLS: Fix busy loop on write error
GH-744 GH-767
* Support 1xx non-final response
aria2 1.27.0 GH-763
============
Release Note
------------
This release fixes bug which may cause crash if UDP tracker is used.
It adds new option --save-not-found which prevents downloads failed by
"not found" error from being saved in session file.
Changes
-------
* Hard-disable openssl in osx build
Closes #739
* Fix possible cause of crash if UDP tracker is used
* Remove custom ftruncate64 for Android
The latest NDK versions support ftruncate64, so building a local
copy of ftruncate64 is no longer needed.
Also, the arm and x86 builds of ftruncate64 failed when targeting
API level 21 or higher, as they include <linux/err.h> which are not
present starting from API level 21.
Patch from Fredrik Fornwall
* Fix typo found by Debian's Lintian
* Add --save-not-found option * Update wslay
* Update comment to match code GH-764
Patch from Torbjörn Lönnemark * Don't download piece which is filtered out (e.g., --select-file)
* WinTLS: Better errors (from WSA) This commit fixes the bug that piece which is not requested by
--select-file is downloaded in multi-file Web-Seeding.
* Compile with openssl 1.1.0 GH-769
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for aria2 1.27.1. # Generated by GNU Autoconf 2.69 for aria2 1.29.0.
# #
# Report bugs to <https://github.com/aria2/aria2/issues>. # Report bugs to <https://github.com/aria2/aria2/issues>.
# #
...@@ -590,8 +590,8 @@ MAKEFLAGS= ...@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='aria2' PACKAGE_NAME='aria2'
PACKAGE_TARNAME='aria2' PACKAGE_TARNAME='aria2'
PACKAGE_VERSION='1.27.1' PACKAGE_VERSION='1.29.0'
PACKAGE_STRING='aria2 1.27.1' PACKAGE_STRING='aria2 1.29.0'
PACKAGE_BUGREPORT='https://github.com/aria2/aria2/issues' PACKAGE_BUGREPORT='https://github.com/aria2/aria2/issues'
PACKAGE_URL='https://aria2.github.io/' PACKAGE_URL='https://aria2.github.io/'
...@@ -1591,7 +1591,7 @@ if test "$ac_init_help" = "long"; then ...@@ -1591,7 +1591,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures aria2 1.27.1 to adapt to many kinds of systems. \`configure' configures aria2 1.29.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
...@@ -1663,7 +1663,7 @@ fi ...@@ -1663,7 +1663,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of aria2 1.27.1:";; short | recursive ) echo "Configuration of aria2 1.29.0:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
...@@ -1866,7 +1866,7 @@ fi ...@@ -1866,7 +1866,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
aria2 configure 1.27.1 aria2 configure 1.29.0
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
...@@ -2874,7 +2874,7 @@ cat >config.log <<_ACEOF ...@@ -2874,7 +2874,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by aria2 $as_me 1.27.1, which was It was created by aria2 $as_me 1.29.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
...@@ -3853,7 +3853,7 @@ fi ...@@ -3853,7 +3853,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='aria2' PACKAGE='aria2'
VERSION='1.27.1' VERSION='1.29.0'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
...@@ -27405,7 +27405,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ...@@ -27405,7 +27405,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by aria2 $as_me 1.27.1, which was This file was extended by aria2 $as_me 1.29.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
...@@ -27472,7 +27472,7 @@ _ACEOF ...@@ -27472,7 +27472,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
aria2 config.status 1.27.1 aria2 config.status 1.29.0
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"
...@@ -28712,7 +28712,6 @@ $as_echo X"$file" | ...@@ -28712,7 +28712,6 @@ $as_echo X"$file" |
cat <<_LT_EOF >> "$cfgfile" cat <<_LT_EOF >> "$cfgfile"
#! $SHELL #! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION # Generated automatically by $as_me ($PACKAGE) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh. # NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services. # Provide generalized library-building support services.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
# #
AC_PREREQ([2.67]) AC_PREREQ([2.67])
AC_INIT([aria2],[1.27.1],[https://github.com/aria2/aria2/issues],[aria2],[https://aria2.github.io/]) AC_INIT([aria2],[1.29.0],[https://github.com/aria2/aria2/issues],[aria2],[https://aria2.github.io/])
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
......
...@@ -19108,7 +19108,6 @@ $as_echo "$as_me: executing $ac_file commands" >&6;} ...@@ -19108,7 +19108,6 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
cat <<_LT_EOF >> "$cfgfile" cat <<_LT_EOF >> "$cfgfile"
#! $SHELL #! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION # Generated automatically by $as_me ($PACKAGE) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh. # NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services. # Provide generalized library-building support services.
......
...@@ -145,10 +145,15 @@ enum wslay_opcode { ...@@ -145,10 +145,15 @@ enum wslay_opcode {
#define wslay_is_ctrl_frame(opcode) ((opcode >> 3) & 1) #define wslay_is_ctrl_frame(opcode) ((opcode >> 3) & 1)
/* /*
* Macros that returns reserved bits: RSV1, RSV2, RSV3. These macros * Macros that represent and return reserved bits: RSV1, RSV2, RSV3.
* assumes that rsv is constructed by ((RSV1 << 2) | (RSV2 << 1) | * These macros assume that rsv is constructed by ((RSV1 << 2) |
* RSV3) * (RSV2 << 1) | RSV3)
*/ */
#define WSLAY_RSV_NONE ((uint8_t) 0)
#define WSLAY_RSV1_BIT (((uint8_t) 1) << 2)
#define WSLAY_RSV2_BIT (((uint8_t) 1) << 1)
#define WSLAY_RSV3_BIT (((uint8_t) 1) << 0)
#define wslay_get_rsv1(rsv) ((rsv >> 2) & 1) #define wslay_get_rsv1(rsv) ((rsv >> 2) & 1)
#define wslay_get_rsv2(rsv) ((rsv >> 1) & 1) #define wslay_get_rsv2(rsv) ((rsv >> 1) & 1)
#define wslay_get_rsv3(rsv) (rsv & 1) #define wslay_get_rsv3(rsv) (rsv & 1)
...@@ -201,7 +206,7 @@ void wslay_frame_context_free(wslay_frame_context_ptr ctx); ...@@ -201,7 +206,7 @@ void wslay_frame_context_free(wslay_frame_context_ptr ctx);
* 1 if this is masked frame, otherwise 0. iocb->payload_length is * 1 if this is masked frame, otherwise 0. iocb->payload_length is
* the payload_length of this frame. iocb->data must point to the * the payload_length of this frame. iocb->data must point to the
* payload data to be sent. iocb->data_length must be the length of * payload data to be sent. iocb->data_length must be the length of
* the data. This function calls recv_callback function if it needs * the data. This function calls send_callback function if it needs
* to send bytes. This function calls gen_mask_callback function if * to send bytes. This function calls gen_mask_callback function if
* it needs new mask key. This function returns the number of payload * it needs new mask key. This function returns the number of payload
* bytes sent. Please note that it does not include any number of * bytes sent. Please note that it does not include any number of
...@@ -407,6 +412,16 @@ int wslay_event_context_client_init ...@@ -407,6 +412,16 @@ int wslay_event_context_client_init
*/ */
void wslay_event_context_free(wslay_event_context_ptr ctx); void wslay_event_context_free(wslay_event_context_ptr ctx);
/*
* Sets a bit mask of allowed reserved bits.
* Currently only permitted values are WSLAY_RSV1_BIT to allow PMCE
* extension (see RFC-7692) or WSLAY_RSV_NONE to disable.
*
* Default: WSLAY_RSV_NONE
*/
void wslay_event_config_set_allowed_rsv_bits(wslay_event_context_ptr ctx,
uint8_t rsv);
/* /*
* Enables or disables buffering of an entire message for non-control * Enables or disables buffering of an entire message for non-control
* frames. If val is 0, buffering is enabled. Otherwise, buffering is * frames. If val is 0, buffering is enabled. Otherwise, buffering is
...@@ -550,6 +565,12 @@ struct wslay_event_msg { ...@@ -550,6 +565,12 @@ struct wslay_event_msg {
int wslay_event_queue_msg(wslay_event_context_ptr ctx, int wslay_event_queue_msg(wslay_event_context_ptr ctx,
const struct wslay_event_msg *arg); const struct wslay_event_msg *arg);
/*
* Extended version of wslay_event_queue_msg which allows to set reserved bits.
*/
int wslay_event_queue_msg_ex(wslay_event_context_ptr ctx,
const struct wslay_event_msg *arg, uint8_t rsv);
/* /*
* Specify "source" to generate message. * Specify "source" to generate message.
*/ */
...@@ -607,6 +628,13 @@ struct wslay_event_fragmented_msg { ...@@ -607,6 +628,13 @@ struct wslay_event_fragmented_msg {
int wslay_event_queue_fragmented_msg int wslay_event_queue_fragmented_msg
(wslay_event_context_ptr ctx, const struct wslay_event_fragmented_msg *arg); (wslay_event_context_ptr ctx, const struct wslay_event_fragmented_msg *arg);
/*
* Extended version of wslay_event_queue_fragmented_msg which allows to set
* reserved bits.
*/
int wslay_event_queue_fragmented_msg_ex(wslay_event_context_ptr ctx,
const struct wslay_event_fragmented_msg *arg, uint8_t rsv);
/* /*
* Queues close control frame. This function is provided just for * Queues close control frame. This function is provided just for
* convenience. wslay_event_queue_msg() can queue a close control * convenience. wslay_event_queue_msg() can queue a close control
......
...@@ -206,7 +206,7 @@ static int wslay_event_imsg_append_chunk(struct wslay_event_imsg *m, size_t len) ...@@ -206,7 +206,7 @@ static int wslay_event_imsg_append_chunk(struct wslay_event_imsg *m, size_t len)
} }
static int wslay_event_omsg_non_fragmented_init static int wslay_event_omsg_non_fragmented_init
(struct wslay_event_omsg **m, uint8_t opcode, (struct wslay_event_omsg **m, uint8_t opcode, uint8_t rsv,
const uint8_t *msg, size_t msg_length) const uint8_t *msg, size_t msg_length)
{ {
*m = (struct wslay_event_omsg*)malloc(sizeof(struct wslay_event_omsg)); *m = (struct wslay_event_omsg*)malloc(sizeof(struct wslay_event_omsg));
...@@ -216,6 +216,7 @@ static int wslay_event_omsg_non_fragmented_init ...@@ -216,6 +216,7 @@ static int wslay_event_omsg_non_fragmented_init
memset(*m, 0, sizeof(struct wslay_event_omsg)); memset(*m, 0, sizeof(struct wslay_event_omsg));
(*m)->fin = 1; (*m)->fin = 1;
(*m)->opcode = opcode; (*m)->opcode = opcode;
(*m)->rsv = rsv;
(*m)->type = WSLAY_NON_FRAGMENTED; (*m)->type = WSLAY_NON_FRAGMENTED;
if(msg_length) { if(msg_length) {
(*m)->data = (uint8_t*)malloc(msg_length); (*m)->data = (uint8_t*)malloc(msg_length);
...@@ -230,7 +231,7 @@ static int wslay_event_omsg_non_fragmented_init ...@@ -230,7 +231,7 @@ static int wslay_event_omsg_non_fragmented_init
} }
static int wslay_event_omsg_fragmented_init static int wslay_event_omsg_fragmented_init
(struct wslay_event_omsg **m, uint8_t opcode, (struct wslay_event_omsg **m, uint8_t opcode, uint8_t rsv,
const union wslay_event_msg_source source, const union wslay_event_msg_source source,
wslay_event_fragmented_msg_callback read_callback) wslay_event_fragmented_msg_callback read_callback)
{ {
...@@ -240,6 +241,7 @@ static int wslay_event_omsg_fragmented_init ...@@ -240,6 +241,7 @@ static int wslay_event_omsg_fragmented_init
} }
memset(*m, 0, sizeof(struct wslay_event_omsg)); memset(*m, 0, sizeof(struct wslay_event_omsg));
(*m)->opcode = opcode; (*m)->opcode = opcode;
(*m)->rsv = rsv;
(*m)->type = WSLAY_FRAGMENTED; (*m)->type = WSLAY_FRAGMENTED;
(*m)->source = source; (*m)->source = source;
(*m)->read_callback = read_callback; (*m)->read_callback = read_callback;
...@@ -301,7 +303,9 @@ int wslay_event_queue_close(wslay_event_context_ptr ctx, uint16_t status_code, ...@@ -301,7 +303,9 @@ int wslay_event_queue_close(wslay_event_context_ptr ctx, uint16_t status_code,
} else { } else {
ncode = htons(status_code); ncode = htons(status_code);
memcpy(msg, &ncode, 2); memcpy(msg, &ncode, 2);
memcpy(msg+2, reason, reason_length); if(reason_length) {
memcpy(msg+2, reason, reason_length);
}
msg_length = reason_length+2; msg_length = reason_length+2;
} }
arg.opcode = WSLAY_CONNECTION_CLOSE; arg.opcode = WSLAY_CONNECTION_CLOSE;
...@@ -328,19 +332,33 @@ static int wslay_event_queue_close_wrapper ...@@ -328,19 +332,33 @@ static int wslay_event_queue_close_wrapper
return 0; return 0;
} }
static int wslay_event_verify_rsv_bits(wslay_event_context_ptr ctx, uint8_t rsv)
{
return ((rsv & ~ctx->allowed_rsv_bits) == 0);
}
int wslay_event_queue_msg(wslay_event_context_ptr ctx, int wslay_event_queue_msg(wslay_event_context_ptr ctx,
const struct wslay_event_msg *arg) const struct wslay_event_msg *arg)
{
return wslay_event_queue_msg_ex(ctx, arg, WSLAY_RSV_NONE);
}
int wslay_event_queue_msg_ex(wslay_event_context_ptr ctx,
const struct wslay_event_msg *arg, uint8_t rsv)
{ {
int r; int r;
struct wslay_event_omsg *omsg; struct wslay_event_omsg *omsg;
if(!wslay_event_is_msg_queueable(ctx)) { if(!wslay_event_is_msg_queueable(ctx)) {
return WSLAY_ERR_NO_MORE_MSG; return WSLAY_ERR_NO_MORE_MSG;
} }
if(wslay_is_ctrl_frame(arg->opcode) && arg->msg_length > 125) { /* RSV1 is not allowed for control frames */
if((wslay_is_ctrl_frame(arg->opcode) &&
(arg->msg_length > 125 || wslay_get_rsv1(rsv)))
|| !wslay_event_verify_rsv_bits(ctx, rsv)) {
return WSLAY_ERR_INVALID_ARGUMENT; return WSLAY_ERR_INVALID_ARGUMENT;
} }
if((r = wslay_event_omsg_non_fragmented_init if((r = wslay_event_omsg_non_fragmented_init
(&omsg, arg->opcode, arg->msg, arg->msg_length)) != 0) { (&omsg, arg->opcode, rsv, arg->msg, arg->msg_length)) != 0) {
return r; return r;
} }
if(wslay_is_ctrl_frame(arg->opcode)) { if(wslay_is_ctrl_frame(arg->opcode)) {
...@@ -359,17 +377,24 @@ int wslay_event_queue_msg(wslay_event_context_ptr ctx, ...@@ -359,17 +377,24 @@ int wslay_event_queue_msg(wslay_event_context_ptr ctx,
int wslay_event_queue_fragmented_msg int wslay_event_queue_fragmented_msg
(wslay_event_context_ptr ctx, const struct wslay_event_fragmented_msg *arg) (wslay_event_context_ptr ctx, const struct wslay_event_fragmented_msg *arg)
{
return wslay_event_queue_fragmented_msg_ex(ctx, arg, WSLAY_RSV_NONE);
}
int wslay_event_queue_fragmented_msg_ex(wslay_event_context_ptr ctx,
const struct wslay_event_fragmented_msg *arg, uint8_t rsv)
{ {
int r; int r;
struct wslay_event_omsg *omsg; struct wslay_event_omsg *omsg;
if(!wslay_event_is_msg_queueable(ctx)) { if(!wslay_event_is_msg_queueable(ctx)) {
return WSLAY_ERR_NO_MORE_MSG; return WSLAY_ERR_NO_MORE_MSG;
} }
if(wslay_is_ctrl_frame(arg->opcode)) { if(wslay_is_ctrl_frame(arg->opcode) ||
!wslay_event_verify_rsv_bits(ctx, rsv)) {
return WSLAY_ERR_INVALID_ARGUMENT; return WSLAY_ERR_INVALID_ARGUMENT;
} }
if((r = wslay_event_omsg_fragmented_init if((r = wslay_event_omsg_fragmented_init
(&omsg, arg->opcode, arg->source, arg->read_callback)) != 0) { (&omsg, arg->opcode, rsv, arg->source, arg->read_callback)) != 0) {
return r; return r;
} }
if((r = wslay_queue_push(ctx->send_queue, omsg)) != 0) { if((r = wslay_queue_push(ctx->send_queue, omsg)) != 0) {
...@@ -547,9 +572,11 @@ int wslay_event_recv(wslay_event_context_ptr ctx) ...@@ -547,9 +572,11 @@ int wslay_event_recv(wslay_event_context_ptr ctx)
r = wslay_frame_recv(ctx->frame_ctx, &iocb); r = wslay_frame_recv(ctx->frame_ctx, &iocb);
if(r >= 0) { if(r >= 0) {
int new_frame = 0; int new_frame = 0;
/* We only allow rsv == 0 ATM. */ /* RSV1 is not allowed on control and continuation frames */
if(iocb.rsv != 0 || if((!wslay_event_verify_rsv_bits(ctx, iocb.rsv)) ||
((ctx->server && !iocb.mask) || (!ctx->server && iocb.mask))) { (wslay_get_rsv1(iocb.rsv) && (wslay_is_ctrl_frame(iocb.opcode) ||
iocb.opcode == WSLAY_CONTINUATION_FRAME)) ||
(ctx->server && !iocb.mask) || (!ctx->server && iocb.mask)) {
if((r = wslay_event_queue_close_wrapper if((r = wslay_event_queue_close_wrapper
(ctx, WSLAY_CODE_PROTOCOL_ERROR, NULL, 0)) != 0) { (ctx, WSLAY_CODE_PROTOCOL_ERROR, NULL, 0)) != 0) {
return r; return r;
...@@ -608,8 +635,10 @@ int wslay_event_recv(wslay_event_context_ptr ctx) ...@@ -608,8 +635,10 @@ int wslay_event_recv(wslay_event_context_ptr ctx)
} }
} }
} }
if(ctx->imsg->opcode == WSLAY_TEXT_FRAME || /* If RSV1 bit is set then it is too early for utf-8 validation */
ctx->imsg->opcode == WSLAY_CONNECTION_CLOSE) { if((!wslay_get_rsv1(ctx->imsg->rsv) &&
ctx->imsg->opcode == WSLAY_TEXT_FRAME) ||
ctx->imsg->opcode == WSLAY_CONNECTION_CLOSE) {
size_t i; size_t i;
if(ctx->imsg->opcode == WSLAY_CONNECTION_CLOSE) { if(ctx->imsg->opcode == WSLAY_CONNECTION_CLOSE) {