Skip to content

Commit 1d15e6b

Browse files
committed
merge RC_1_1 into master
2 parents d0f5522 + f080149 commit 1d15e6b

18 files changed

+251
-129
lines changed

ChangeLog

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979

8080
1.1.5 release
8181

82+
* fix parsing of torrents with certain invalid filenames
83+
* fix leak of torrent_peer objecs (entries in peer_list)
8284
* fix leak of peer_class objects (when setting per-torrent rate limits)
8385
* expose peer_class API to python binding
8486
* fix integer overflow in whole_pieces_threshold logic

Jamfile

+99-26
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,24 @@ VERSION = 1.2.0 ;
4747

4848
# rule for linking the correct libraries depending
4949
# on features and target-os
50-
rule linking ( properties * )
50+
rule link-openssl ( properties * )
5151
{
5252
local result ;
5353

5454
# openssl libraries, if enabled
5555
# exclude gcc from a regular windows build to make mingw
5656
# link against the regular unix library name
57-
if <crypto>openssl in $(properties)
57+
if <openssl-version>pre1.1 in $(properties)
58+
&& <target-os>windows in $(properties)
59+
&& ! <toolset>gcc in $(properties)
5860
{
59-
if <openssl-version>pre1.1 in $(properties)
60-
&& <target-os>windows in $(properties)
61-
&& ! <toolset>gcc in $(properties)
62-
{
63-
result += <library>ssleay32 <library>libeay32 ;
64-
}
65-
else
66-
{
67-
# on windows the library names were changed to be in line with other
68-
# system starting with OpenSSL 1.1
69-
result += <library>crypto <library>ssl ;
70-
}
61+
result += <library>ssleay32 <library>libeay32 ;
62+
}
63+
else
64+
{
65+
# on windows the library names were changed to be in line with other
66+
# system starting with OpenSSL 1.1
67+
result += <library>crypto <library>ssl ;
7168
}
7269

7370
if <crypto>libcrypto in $(properties)
@@ -88,9 +85,7 @@ rule linking ( properties * )
8885
}
8986

9087
# windows needs some more libraries when using openSSL
91-
if ( <crypto>openssl in $(properties)
92-
|| <crypto>libcrypto in $(propertes) )
93-
&& <target-os>windows in $(properties)
88+
if <target-os>windows in $(properties)
9489
&& ! <toolset>gcc in $(properties)
9590
{
9691
result += <library>advapi32
@@ -99,7 +94,13 @@ rule linking ( properties * )
9994
<library>gdi32
10095
;
10196
}
97+
echo "link openssl = " $(result) ;
98+
return $(result) ;
99+
}
102100

101+
rule linking ( properties * )
102+
{
103+
local result ;
103104
if <simulator>on in $(properties)
104105
{
105106
result += <library>/libsimulator//simulator ;
@@ -375,7 +376,7 @@ rule default-build ( properties * )
375376
return $(result) ;
376377
}
377378

378-
rule tag ( name : type ? : property-set )
379+
rule tag ( name : type ? : property-set )
379380
{
380381
name = [ virtual-target.add-prefix-and-suffix $(name) : $(type) : $(property-set) ] ;
381382

@@ -388,6 +389,78 @@ rule tag ( name : type ? : property-set )
388389
return $(name) ;
389390
}
390391

392+
# the search path to pick up the openssl libraries from. This is the <search>
393+
# property of those libraries
394+
rule openssl-lib-path ( properties * )
395+
{
396+
local OPENSSL_LIB = [ feature.get-values <openssl-lib> : $(properties) ] ;
397+
398+
if <target-os>darwin in $(properties) && $(OPENSSL_LIB) = ""
399+
{
400+
# on macOS, default to pick up openssl from the homebrew installation
401+
# brew install openssl
402+
OPENSSL_LIB = /usr/local/opt/openssl/lib ;
403+
}
404+
else if <target-os>windows in $(properties)
405+
&& <toolset>gcc in $(properties)
406+
&& $(OPENSSL_LIB) = ""
407+
{
408+
# on mingw, assume openssl is installed in c:\OpenSSL-Win32 by default
409+
OPENSSL_LIB = c:\\OpenSSL-Win32\\lib ;
410+
}
411+
else if <target-os>windows in $(properties) && $(OPENSSL_LIB) = ""
412+
{
413+
# on windows, just assume openssl is installed to c:\openssl
414+
if <address-model>64 in $(properties)
415+
{ OPENSSL_LIB = c:\\openssl\\lib64 ; }
416+
else
417+
{ OPENSSL_LIB = c:\\openssl\\lib ; }
418+
}
419+
420+
local result ;
421+
result += <search>$(OPENSSL_LIB) ;
422+
echo "openssl-lib-path = " $(result) ;
423+
return $(result) ;
424+
}
425+
426+
# the include path to pick up openssl headers from. This is the
427+
# usage-requirement for the openssl-related libraries
428+
rule openssl-include-path ( properties * )
429+
{
430+
local OPENSSL_INCLUDE = [ feature.get-values <openssl-include> : $(properties) ] ;
431+
432+
if <target-os>darwin in $(properties) && $(OPENSSL_INCLUDE) = ""
433+
{
434+
# on macOS, default to pick up openssl from the homebrew installation
435+
# brew install openssl
436+
OPENSSL_INCLUDE = /usr/local/opt/openssl/include ;
437+
}
438+
else if <target-os>windows in $(properties)
439+
&& <toolset>gcc in $(properties)
440+
&& $(OPENSSL_INCLUDE) = ""
441+
{
442+
# on mingw, assume openssl is installed in c:\OpenSSL-Win32 by default
443+
OPENSSL_INCLUDE = c:\\OpenSSL-Win32\\include ;
444+
}
445+
else if <target-os>windows in $(properties) && $(OPENSSL_INCLUDE) = ""
446+
{
447+
# on windows, just assume openssl is installed to c:\openssl
448+
# not sure if there's a better way to find out where it may be
449+
if <address-model>64 in $(properties)
450+
{ OPENSSL_INCLUDE = c:\\openssl\\include64 ; }
451+
else
452+
{ OPENSSL_INCLUDE = c:\\openssl\\include ; }
453+
}
454+
455+
local result ;
456+
result += <include>$(OPENSSL_INCLUDE) ;
457+
echo "openssl-include-path = " $(result) ;
458+
return $(result) ;
459+
}
460+
461+
feature openssl-lib : : free path ;
462+
feature openssl-include : : free path ;
463+
391464
feature ipv6 : on off : composite propagated link-incompatible ;
392465
feature.compose <ipv6>off : <define>TORRENT_USE_IPV6=0 ;
393466

@@ -515,9 +588,12 @@ variant test_arm : debug
515588
<export-extra>on <asserts>on
516589
;
517590

591+
lib crypto : : <name>crypto <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
592+
lib ssl : : <name>ssl <use>crypto <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
593+
518594
# required for openssl on windows
519-
lib ssleay32 : : <name>ssleay32 ;
520-
lib libeay32 : : <name>libeay32 ;
595+
lib ssleay32 : : <name>ssleay32 <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
596+
lib libeay32 : : <name>libeay32 <conditional>@openssl-lib-path : : <conditional>@openssl-include-path ;
521597
lib advapi32 : : <name>advapi32 ;
522598
lib user32 : : <name>user32 ;
523599
lib shell32 : : <name>shell32 ;
@@ -534,12 +610,7 @@ lib libiconv : : <name>iconv <link>shared <search>/usr/local/lib ;
534610
# openssl on linux/bsd etc.
535611
lib gcrypt : : <name>gcrypt <link>shared <search>/opt/local/lib ;
536612

537-
# pick up openssl on macos from brew
538-
lib crypto : : <name>crypto <target-os>darwin <search>/usr/local/opt/openssl/lib : <link>shared : <include>/usr/local/opt/openssl/include ;
539-
lib ssl : : <name>ssl <use>crypto <target-os>darwin <search>/usr/local/opt/openssl/lib : <link>shared : <include>/usr/local/opt/openssl/include ;
540-
541-
lib crypto : : <name>crypto : <link>shared ;
542-
lib ssl : : <name>ssl <use>crypto : <link>shared ;
613+
alias openssl-libraries : : : : <conditional>@link-openssl ;
543614

544615
lib libsocket : : <use>libnsl <name>socket <link>shared <search>/usr/sfw/lib <link>shared ;
545616
lib libnsl : : <name>nsl <link>shared <search>/usr/sfw/lib <link>shared ;
@@ -754,6 +825,8 @@ lib torrent
754825
<link>shared:<define>TORRENT_BUILDING_SHARED
755826
<define>BOOST_NO_DEPRECATED
756827
<link>shared:<define>BOOST_SYSTEM_SOURCE
828+
<crypto>openssl:<library>openssl-libraries
829+
<crypto>libcrypto:<library>openssl-libraries
757830

758831
<dht>on:<source>src/kademlia/$(KADEMLIA_SOURCES).cpp
759832
<dht>on:<source>ed25519/src/$(ED25519_SOURCES).cpp

appveyor.yml

+11-12
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ environment:
2020
model: 64
2121
python: 1
2222
crypto: openssl
23-
linkflags: 'linkflags="/LIBPATH:C:\\openssl-1.0.1p-vs2015\\lib64"'
24-
include: 'include="c:\\openssl-1.0.1p-vs2015\\include"'
2523
- variant: test_debug
2624
compiler: gcc
2725
model: 32
@@ -38,10 +36,11 @@ install:
3836
- if %compiler% == msvc-14.0 if defined crypto (
3937
echo extracting openssl-2015
4038
& 7z x -oc:\ -aoa openssl-1.0.1p-vs2015.7z > nul
41-
& copy c:\openssl-1.0.1p-vs2015\lib64\ssleay32MT.lib c:\openssl-1.0.1p-vs2015\lib64\ssleay32.lib
42-
& copy c:\openssl-1.0.1p-vs2015\lib64\libeay32MT.lib c:\openssl-1.0.1p-vs2015\lib64\libeay32.lib
43-
& copy c:\openssl-1.0.1p-vs2015\lib\ssleay32MT.lib c:\openssl-1.0.1p-vs2015\lib\ssleay32.lib
44-
& copy c:\openssl-1.0.1p-vs2015\lib\libeay32MT.lib c:\openssl-1.0.1p-vs2015\lib\libeay32.lib
39+
& rename c:\openssl-1.0.1p-vs2015 openssl
40+
& copy c:\openssl\lib64\ssleay32MT.lib c:\openssl\lib64\ssleay32.lib
41+
& copy c:\openssl\lib64\libeay32MT.lib c:\openssl\lib64\libeay32.lib
42+
& copy c:\openssl\lib\ssleay32MT.lib c:\openssl\lib\ssleay32.lib
43+
& copy c:\openssl\lib\libeay32MT.lib c:\openssl\lib\libeay32.lib
4544
)
4645
- if not defined crypto ( set crypto=built-in )
4746
- if not defined linkflags ( set linkflags="" )
@@ -69,32 +68,32 @@ cache:
6968
build_script:
7069
# examples
7170
- cd %ROOT_DIRECTORY%\examples
72-
- b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto%
71+
- b2.exe --hash crypto=openssl openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto%
7372

7473
# tools
7574
- cd %ROOT_DIRECTORY%\tools
76-
- b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto%
75+
- b2.exe --hash crypto=openssl openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto%
7776

7877
# test
7978
- cd %ROOT_DIRECTORY%\test
80-
- b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% win-tests test_upnp test_natpmp testing.execute=off
79+
- b2.exe --hash crypto=openssl openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% win-tests test_upnp test_natpmp testing.execute=off
8180

8281
# python binding
8382
- cd %ROOT_DIRECTORY%\bindings\python
8483
# we use 64 bit python builds
8584
- if defined python (
86-
b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% libtorrent-link=shared stage_module stage_dependencies
85+
b2.exe --hash crypto=openssl openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% libtorrent-link=shared stage_module stage_dependencies
8786
)
8887

8988
# simulations
9089
- cd %ROOT_DIRECTORY%\simulation
9190
- if defined sim (
92-
b2.exe --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% deprecated-functions=off %linkflags% %include% link=shared crypto=built-in testing.execute=off
91+
b2.exe --hash crypto=openssl openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% deprecated-functions=off %linkflags% %include% link=shared crypto=built-in testing.execute=off
9392
)
9493

9594
test_script:
9695
- cd %ROOT_DIRECTORY%\test
97-
- appveyor-retry b2.exe -l400 --hash openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% win-tests
96+
- appveyor-retry b2.exe -l400 --hash crypto=openssl openssl-version=pre1.1 warnings-as-errors=on -j2 %compiler% address-model=%model% debug-iterators=on picker-debugging=on invariant-checks=full variant=%variant% %linkflags% %include% link=shared crypto=%crypto% win-tests
9897

9998
- cd %ROOT_DIRECTORY%\bindings\python
10099
# we use 64 bit python build

build_dist.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ rm -f bindings/python/Makefile bindings/python/Makefile.in
2323
chmod a-x docs/*.rst docs/*.htm* src/*.cpp include/libtorrent/*.hpp
2424

2525
./autotool.sh
26-
./configure --enable-python-binding --enable-examples=yes --enable-encryption --enable-tests=yes --with-boost-system=mt --with-boost-python=mt
26+
./configure --enable-python-binding --enable-examples=yes --enable-encryption --enable-tests=yes --with-boost-system=mt --with-boost-chrono=mt --with-boost-random=mt --with-boost-python=mt --with-openssl=/usr/local/opt/openssl
2727
make V=1 -j8 check
2828

29-
./configure --enable-python-binding --enable-examples=yes --enable-encryption --with-boost-system=mt --with-boost-python=mt
29+
./configure --enable-python-binding --enable-examples=yes --enable-encryption --with-boost-system=mt --with-boost-chrono=mt --with-boost-random=mt --with-boost-python=mt --with-openssl=/usr/local/opt/openssl
3030
make V=1 -j8 dist
3131

docs/building.rst

+19-3
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ windows format (``c:/boost_1_64_0``).
237237
The ``Jamfile`` will define ``NDEBUG`` when it's building a release build.
238238
For more build configuration flags see `Build configurations`_.
239239

240+
When enabling linking against openssl (by setting the ``crypto`` feature to
241+
``openssl``) the Jamfile will look in some default directory for the openssl
242+
headers and libraries. On macOS, it will look for the homebrew openssl package.
243+
On windows it will look in ``c:\openssl`` and mingw in ``c:\OpenSSL-Win32``.
244+
245+
To customize the library path and include path for openssl, set the features
246+
``openssl-lib`` and ``openssl-include`` respectively.
247+
240248
Build features:
241249

242250
+--------------------------+----------------------------------------------------+
@@ -247,6 +255,13 @@ Build features:
247255
| | * ``shared`` - links dynamically against the boost |
248256
| | libraries. |
249257
+--------------------------+----------------------------------------------------+
258+
| ``openssl-lib`` | can be used to specify the directory where libssl |
259+
| | and libcrypto are installed (or the windows |
260+
| | counterparts). |
261+
+--------------------------+----------------------------------------------------+
262+
| ``openssl-include`` | can be used to specify the include directory where |
263+
| | the openssl headers are installed. |
264+
+--------------------------+----------------------------------------------------+
250265
| ``logging`` | * ``off`` - logging alerts disabled. The |
251266
| | reason to disable logging is to keep the binary |
252267
| | size low where that matters. |
@@ -281,9 +296,10 @@ Build features:
281296
| ``crypto`` | * ``built-in`` - (default) uses built-in SHA-1 |
282297
| | implementation. In macOS/iOS it uses |
283298
| | CommonCrypto SHA-1 implementation. |
284-
| | * ``openssl`` - links against openssl to enable |
285-
| | torrents over ssl feature. |
286-
| | the option crypto=libcrypto. |
299+
| | * ``openssl`` - links against openssl and |
300+
| | libcrypto to use for SHA-1 hashing. |
301+
| | This also enables HTTPS-tracker support and |
302+
| | support for bittorrent over SSL. |
287303
| | * ``libcrypto`` - links against libcrypto |
288304
| | to use the SHA-1 implementation. |
289305
| | * ``gcrypt`` - links against libgcrypt |

include/libtorrent/aux_/session_impl.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ namespace aux {
294294
void reopen_listen_sockets();
295295
void reopen_outgoing_sockets();
296296

297-
torrent_peer_allocator_interface* get_peer_allocator() override
298-
{ return &m_peer_allocator; }
297+
torrent_peer_allocator_interface& get_peer_allocator() override
298+
{ return m_peer_allocator; }
299299

300300
io_service& get_io_service() override { return m_io_service; }
301301
resolver_interface& get_resolver() override { return m_host_resolver; }

include/libtorrent/aux_/session_interface.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ namespace libtorrent { namespace aux {
147147

148148
virtual alert_manager& alerts() = 0;
149149

150-
virtual torrent_peer_allocator_interface* get_peer_allocator() = 0;
150+
virtual torrent_peer_allocator_interface& get_peer_allocator() = 0;
151151
virtual io_service& get_io_service() = 0;
152152
virtual resolver_interface& get_resolver() = 0;
153153

include/libtorrent/config.hpp

-12
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,6 @@ POSSIBILITY OF SUCH DAMAGE.
168168
#if TARGET_OS_IPHONE
169169
#define TORRENT_USE_SC_NETWORK_REACHABILITY 1
170170
#endif
171-
172-
#else // __APPLE__
173-
// FreeBSD has a reasonable iconv signature
174-
// unless we're on glibc
175-
#ifndef __GLIBC__
176-
# define TORRENT_ICONV_ARG(x) (x)
177-
#endif
178171
#endif // __APPLE__
179172

180173
#define TORRENT_USE_DEV_RANDOM 1
@@ -328,7 +321,6 @@ POSSIBILITY OF SUCH DAMAGE.
328321
#define TORRENT_USE_IFCONF 1
329322
#define TORRENT_USE_SYSCTL 1
330323
#define TORRENT_USE_IPV6 0
331-
#define TORRENT_ICONV_ARG(x) (x)
332324
#define TORRENT_USE_WRITEV 0
333325
#define TORRENT_USE_READV 0
334326

@@ -355,10 +347,6 @@ POSSIBILITY OF SUCH DAMAGE.
355347
#define TORRENT_NO_RETURN
356348
#endif
357349

358-
#ifndef TORRENT_ICONV_ARG
359-
#define TORRENT_ICONV_ARG(x) const_cast<char**>(x)
360-
#endif
361-
362350
#if defined __GNUC__ || defined __clang__
363351
#define TORRENT_FORMAT(fmt, ellipsis) __attribute__((__format__(__printf__, fmt, ellipsis)))
364352
#else

0 commit comments

Comments
 (0)