Commit Graph

224 Commits

Author SHA1 Message Date
Charles Kerr 2bcab6be7e
refactor: remove tr_dh code (#3443)
Refactor the MSE handshake Diffie-Hellman key code.
2022-07-14 19:54:10 -05:00
Colin B c3db52e310
Fix #3444, support single file hybrid torrents. (#3446) 2022-07-14 13:53:00 -05:00
Charles Kerr 0a39cb9302
refactor: migrate tr_crypto C functions to members (#3430) 2022-07-10 21:57:05 -05:00
Charles Kerr 71bc7143b8
Revert "refactor: tr_address cleanup (#3422)" (#3426)
This reverts commit 9a44eeaa27.
2022-07-09 18:44:20 -05:00
Charles Kerr 9a44eeaa27
refactor: tr_address cleanup (#3422)
* refactor: remove tr_address_compare()

* refactor: remove tr_address_to_string()

* refactor: remove NUM_TR_AF_INET_TYPES

* refactor: replace tr_sessionGetPublicAddress with tr_session::getPublicAddress()

* refactor: tr_peerIo() takes tr_address by value

* refactor: replace tr_sessionIsAddressBlocked with tr_session::isAddressBlocked()

* refactor: tr_peerMgrAddIncoming now takes tr_address by value

* refactor: replace tr_address_is_valid_for_peers() with tr_address.isValidForPeers()

* refactor: tr_netOpenPeerSocket takes tr_address by value

* refactor: remove tr_generateAllowedSet()

* refactor: setup_sockaddr takes a tr_address by value

* refactor: tr_netBindTCP() takes a tr_address by value

* refactor: tr_dhtAddNode() takes a tr_address by value

* refactor: remove tr_address_from_string()

* refactor: rename tr_address.isValidForPeers() to .isValidPeerAddress()

* refactor: replace tr_address_from_sockaddr_storage() with tr_address::fromSockaddrStorage()

* refactor: minor cleanup to tr_address::readable()
2022-07-08 13:23:41 -05:00
Charles Kerr e9a7ddf7f9
fix: minor warnings (#3413)
* fix: signed-unsigned comparison warning

* fix: readability-implicit-bool-conversion warning

* fix: signed-unsigned comparison warning
2022-07-05 18:32:30 -05:00
Charles Kerr 513f4bc91b
fix: assertion failed "s->leftUntilDone <= s->sizeWhenDone" (#3406) 2022-07-04 11:48:54 -05:00
Mike Gelfand 142b2a088d
Support wolfSSL 4.6+ (#3398)
* Fix testing against reference crypto implementation

Build would fail on CI if using cyassl/wolfssl or polarssl/mbedtls as a
backend and testing it against reference openssl implementation due to
missing include directories, but only if bundled (non-system) b64 is
used.

* Iniitalize size arguments to `wc_DhGenerateKeyPair`

Despite it not being mentioned in the documentation [1] and v4.6 release
notes [2], the two size parameters became [3] not purely "out", but
"in/out", to avoid potential buffer overflows.

[1] https://www.wolfssl.com/documentation/manuals/wolfssl/group__Diffie-Hellman.html
[2] https://github.com/wolfSSL/wolfssl/releases/tag/v4.6.0-stable
[3] 4364700c01
2022-07-03 14:05:40 +01:00
Colin B 5e43731bcf
Ensure hybrid torrents are parsed correctly. (#3388) 2022-07-02 12:16:34 -05:00
Colin B 3237323b8e
Add basic support for v2 hashes in transmission-show (#3380)
* Add basic support for v2 hashes in transmission-show

* Add sha256 for more libraries

* Fix issue with sha256 digest length
* Add sha256 for polarssl
    Note: Bumping miniumum PolarSSL version to 1.3 because of
    sha2->sha256 name change.
* Add sha256 for CommonCrypto/ccrypto
* Add sha256 for cyassl
2022-07-01 09:49:33 -05:00
Charles Kerr 85c11b7f03
fix: requests across piece boundaries when piece is not a multiple of block_size
Fixes #3324.
2022-06-19 23:08:58 -05:00
Charles Kerr 25fdb5805c
refactor: use tr_torrent_id_t (#3314)
* refactor: use semantic type tr_torrent_type_t in libtransmission

* refactor: use semantic type tr_torrent_type_t in gtk client

* refactor: use semantic type tr_torrent_type_t in qt client
2022-06-17 10:43:04 -05:00
Charles Kerr 34cb56b2af
refactor: remove unused tr_ptrArray class (#3262)
* refactor: remove unused tr_ptrArray class

* fixup! build: add sanitizer CI runs when libtransmission-test changes (#3260)
2022-06-11 21:45:00 -05:00
Dmytro Lytovchenko d34bd0b4d6
refactor: modernize cache.cc (#3108)
* Modernize cache.cc: Convert tr_cache to a class

* Modernize cache.cc: Replaced ptrArray with vector

* refactor: Cache now takes a tr_torrents reference

* refactor: add Key type to Cache

* refactor: avoid std::back_inserter

* refactor: add Cache::flushOldest()
2022-06-11 19:46:30 -05:00
Charles Kerr 256b436023
fix: clang 15 warnings (#3172)
* fix modernize-macro-to-enum libtransmission warnings

* fix readability-simplify-boolean-expr libtransmission warnings

* fix bugprone-unchecked-optional-access libtransmission warnings
2022-06-01 11:56:59 -05:00
Charles Kerr 84d65d8e61
fix: coverity warnings (#3168)
* fix: uninitialized peer_atom field

* fix: silence inaccurate open-files-test warning

* fix: assertion-is-always-true

asserting unsigned val is >= 0

* fix: unnecessary nullptr check

* fix: nullptr dereference warning
2022-05-31 18:58:20 -05:00
Charles Kerr fe288b45e5
perf: do not use tr_variant when parsing .torrent files 2022-05-23 23:05:16 -05:00
Charles Kerr 19db28c04d
perf: faster detection of invalid filenames (#3126)
* refactor: move file_info into tr_torrent_files

* chore: rename files-test as torrent-files-test.cc

* test: add tests for tr_torrent_files::isSubpathPortable()
2022-05-23 17:53:26 -05:00
Charles Kerr 67a078402d
fix: compiler warnings (#3123)
* fix: unused function warning tr_rpc_address_is_valid

* fix: unused variable warning old_byte_pop

* fix: method-can-be-made-static warning assertValidRules

* fix: signed-unsigned comparison warning

* fix: invalid case style warning for KBps

* chore: disable warning for static class member varaible
2022-05-22 21:22:34 -05:00
Charles Kerr c0bb2d40f1
refactor: add pathbuf and std::string-friendly helpers to tr_sys file and path funcs (#3118)
* refactor: add sv-friendly tr_sys_dir_create() variant

* refactor: add sv-friendly tr_sys_path_get_info() variant

* refactor: add sv-friendly tr_sys_path_exists() variant

* refactor: add sv-friendly tr_sys_path_remove() variant

* refactor: add sv-friendly tr_sys_path_rename() variant

* fixup! refactor: add sv-friendly tr_sys_path_rename() variant
2022-05-21 20:17:00 -05:00
Charles Kerr 690cf50e53
perf: tr_sys_path_dirname() returns a std::string_view (#2990)
* refactor: use nodejs impl of path.win32.dirname()

* refactor: use nodejs impl of path.posix.dirname()
2022-05-21 11:10:58 -05:00
Charles Kerr a28b07b390
Revert "refactor: move tr_torrent callbacks to tr_session (#3003)" (#3104)
This reverts commit 27fbfd8da6.

Fixes #3088.
2022-05-16 13:48:43 -05:00
Charles Kerr 27fbfd8da6
refactor: move tr_torrent callbacks to tr_session (#3003)
* refactor: move tr_torrent callbacks to tr_session

* Support tr_sessionSet* (#3044)

Co-authored-by: Antoine Cœur <coeur@gmx.fr>
2022-05-14 10:00:13 -05:00
Charles Kerr 5dbe1f4669
refactor: replace tr_fdlimit with tr_open_files (#3016) 2022-04-28 21:35:47 -05:00
Charles Kerr 5e769fbc55
refactor: make tr_recentHistory a template class (#3012)
This gives more flexibility on the size of the count bins, so we can save space on smaller counts
2022-04-28 10:52:26 -05:00
Charles Kerr 32facb50d7
refactor: prefer tr_pathbuf over tr_strvPath() (#2966) 2022-04-22 11:35:56 -05:00
Charles Kerr 3643a8aee5
refactor: prefer std::vector as the default container (#2964) 2022-04-22 08:08:02 -05:00
Charles Kerr 41cb8cbc91
refactor: add tr_address.readable (#2962) 2022-04-21 18:37:02 -05:00
Charles Kerr a52edbcbbe
refactor: remove tr_announce_list.tiers (#2960) 2022-04-21 15:48:30 -05:00
Antoine Cœur bdac708762
docs: fix various typos and misspellings (#2955) 2022-04-21 09:28:38 -05:00
Charles Kerr c1faebca6e
fix: new MSVC warning in file-piece-map-test.cc (#2936) 2022-04-16 23:36:05 -05:00
Charles Kerr 6cdc7e3828
refactor: remove tr_announce_list::tracker info.announce (#2931) 2022-04-16 15:41:51 -05:00
Charles Kerr ef4fcf7ffd
refactor: remove tr_announce_list.tracker_info.scrape (#2930) 2022-04-16 14:14:18 -05:00
Charles Kerr 2f97655981
refactor: remove tr_url_parsed_t.portstr (#2929) 2022-04-16 13:13:42 -05:00
Charles Kerr 4a2a6b2985
test: use uniform naming scheme for fuzz tests. (#2928)
Use case: libtransmission-test --gtest_filter='*Fuzz' --gtest_repeat N
2022-04-16 11:47:51 -05:00
Charles Kerr 2866638e1b
refactor: add tr_torrent_files::move() and remove() (#2919) 2022-04-15 18:39:04 -05:00
Charles Kerr ec57d10954
refactor: tr_files::hasAnyLocalData() (#2911) 2022-04-13 21:41:06 -05:00
Charles Kerr 9f9f60f1e3
refactor: tr_block_info (#2908) 2022-04-13 20:22:59 -05:00
Charles Kerr 4a65956cc9
refactor: extract some file management into tr_files class (#2906) 2022-04-12 10:00:02 -05:00
Charles Kerr 205abbbcce
refactor: iwyu string, vector, cstdint (#2898)
* refactor: use cstdint for intX_t types

* refactor: iwyu sstring_view

* refactor: iwyu <cstring>

* refactor: iwyu <vector>
2022-04-07 20:50:26 -05:00
Charles Kerr b256da02e3
refactor: remove unused macros (#2897)
* refactor: remove unused fu nction tr_lowerBound()

* refactor: tr_timerAdd() takes a reference, not a pointer

* refactor: tr_timerAddMsec() takes a reference, not a pointer

* refactor: tr_moveFile() takes a reference, not a pointer

* refactor: tr_wildmat() takes std::string_views

* refactor: remove unused macro TR_GNUC_NONNULL

* refactor: remove unused macro TR_GNUC_PRINTF

* refactor: remove unused macro TR_GNUC_NULL_TERMINATED

* refactor: remove unused macro TR_GNUC_HOT

* refactor: remove unused macro __has_feature

* refactor: remove unused macro __has_attribute

* refactor: remove unused macro TR_DEPRECATED

* refactor: remove unused macro TR_DISABLE_COPY_MOVE
2022-04-07 19:20:29 -05:00
Charles Kerr 31c65eec1f
refactor: remove tr_strvJoin() (#2896) 2022-04-07 17:26:59 -05:00
Charles Kerr ffda5bb68a
refactor: remove tr_strip_positional_args() (#2881)
* refactor: use fmt in gtk/SystemIconTray

* refactor: use fmt in gtk/MakeDialog

* refactor: remove unused tr_strip_positional_args()

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-04-07 08:23:04 -05:00
Charles Kerr f79a75cb21
test: fuzz test tr_variantFromBuf() (#2892)
* test: fuzz test tr_torrent_metainfo.parseBenc()

* fix: better error-checking in benc string parsing

* fix: return benc failure if the parse stack is unbalanced

* fix: stack range error when logging json parse errors

* test: fuzz test tr_variantFromBuf()
2022-04-06 16:39:39 -05:00
Charles Kerr a134445caa
test: fuzz test tr_torrent_metainfo.parseBenc() (#2891)
* test: fuzz test tr_urlParse()

* fix: stack error checking in benc parser

* test: fuzz test tr_torrent_metainfo.parseBenc()
2022-04-06 15:26:13 -05:00
Charles Kerr e88ebbc3e5
test: fuzz test tr_magnet_metainfo.parseMagnet() (#2890) 2022-04-06 13:22:08 -05:00
Charles Kerr eb33b2faf5
fix: tr_clientForId() (#2887)
* fix: memory corruption when parsing negative numbers

* fix: stack-buffer-overflow on escape chars in tr_clientForId

* test: add tr_clientForId() fuzz tests
2022-04-06 12:06:11 -05:00
Charles Kerr 68bec3f8e3
refactor: remove tr_snprintf() (#2872) 2022-04-04 13:36:48 -05:00
Charles Kerr 1d7d17396f
refactor: remove tr_snprintf() pt 2 (#2871) 2022-04-03 13:23:00 -05:00
Charles Kerr 76f44b4b6f
fix: sonarcloud (#2868)
* refactor: make this variable const

* refactor: replace redundant type with auto

* refactor: use the nullptr literal

* refactor: replace declaration by structured binding declaration
2022-04-02 17:42:51 -05:00