Commit Graph

209 Commits

Author SHA1 Message Date
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
Charles Kerr 1cc9da26ba
fix: sonarcloud (#2865)
* refactor: implement FileTreeItem::children_ with a std::vector

* fix: std::move should not be called on forwarding reference

* fix: uninitialized scalar variable

* fix: unchecked return value from library

* fix: dereference before null check

* fix: unchecked return value from library

* fix: unchecked return value from library

* fixup! refactor: implement FileTreeItem::children_ with a std::vector

* fix: signed-unsigned comparison in libtransmission tests

* fix: avoid unnecessary copy by using const reference

* fix: function should be declared const

* refactor: use fmt::format to build log timestamps

* fix: use init-statement to reduce variable scope

* fixup! refactor: use fmt::format to build log timestamps

* fix: remove tau_tracker destructor for rule-of-zero

* fix: remove tr_peerIo destructor for rule-of-zero

* Revert "fix: dereference before null check"

This reverts commit cd78967815.

* fix: signed-unsigned comparison in libtransmission tests

* fix: use init-statement to reduce variable scope

* fix: extract nested code block into separate method

* fix: extract nested code block into separate method

* fix: extract nested code block into separate method

* fix: use init-statement to reduce variable scope

* fix: extract nested code block into separate method

* fix: signed-unsigned comparison in libtransmission tests

* fixup! fix: extract nested code block into separate method

* fix: mark possibly-unused as [[maybe_unused]]

* fix: invalid stack memory reference in tr_found_file_t

* fix: signed-unsigned comparison in libtransmission tests
2022-04-02 09:06:02 -05:00
Charles Kerr a250690f30
fix: sonarcloud (#2860)
* fix: break will never be executed

* fix: rewrite rimraf() to be non-throwing

* fix: conditional operation returns same value whether condition is true or false

* fix: use std::array instead of a C-style array

* fix: remove redundant access specifier

* fix: replace switch with if for readability

* fix: convert integer literal to a bool literal

* fix: replace const std::string reference to std::string_view

* fix: remove redundant access specifier

* fix: replace const std::string reference to std::string_view

* fix: remove unused parameter

* fix: remove redundant access specifier

* fix: use std::array instead of C-style array

* fix: remove redundant access specifier

* fix: replace const std::string reference with std::string_view

* fix: remove redundant access specifier

* fix: use std::array instead of C-style array

* fix: remove redundant access specifier

* fix: replace const std::string reference to std::string_view

* fix: remove redundant access specifier

* fix: merge if statement with enclosing one

* chore: clang-format

* chore: clang-format

* Revert "fix: remove redundant access specifier"

This reverts commit 054e4e7eec.

* Revert "fix: remove redundant access specifier"

This reverts commit 2c92f227e8.

* Revert "fix: remove redundant access specifier"

This reverts commit a0710202a8.

* Revert "fix: remove redundant access specifier"

This reverts commit 54da1d9397.

* Revert "fix: remove redundant access specifier"

This reverts commit f7b1777578.

* Revert "fix: remove redundant access specifier"

This reverts commit ad8e3dfff4.

* chore: revert access specifier change
2022-04-01 14:16:33 -05:00
Charles Kerr e64430941f
refactor: remove tr_strdup_printf() (#2854) 2022-03-31 19:13:37 -05:00
Charles Kerr 6e91136b53
fix: three asan issues (#2851)
* fixup! feat: add support for adding torrents by raw hash values (#2608)

fix array-bounds-read issue found by asan

* fixup! refactor: tr_completion (#2220)

fix array-bounds-read issue in tests fixtures

* fixup! refactor: tr_torrents (#2722)

fix memory leak in torrent-tests
2022-03-31 12:12:54 -05:00
Charles Kerr 4dd25d8112
fix: tr_strbuf move op loses zero-termination (#2843) 2022-03-30 12:10:51 -05:00
Charles Kerr 66638cc80c
test: fix race condition in move-test (#2841) 2022-03-30 01:30:39 -05:00
Charles Kerr 2996e223dd
refactor: strbuf for metainfo files (#2833)
* refactor: tr_ctorSaveContents takes a string_view filename

* refactor: remove tr_ctorSaveMagnetContents

* refactor: announce_list::save takes a std::string_view

* refactor: magnet() takes an OutputIt arg

Generate the magnet link URL into an output iterator

* refactor: remove deprecated calls to tr_http_escape

* refactor: tr_torrent.torrentFile takes an OutputIterator

* refactor: tr_torrent.torrentFile returns a tr_pathbuf

* refactor: tr_torrent_metainfo.makeFilename returns a tr_pathbuf

* refactor: use tr_urlbuf in announcer-http
2022-03-28 17:13:32 -05:00
Charles Kerr 9d141ee2b1
refactor: add fmt::formatters (#2829)
* refactor: add fmt::formatters
2022-03-27 21:55:30 -05:00
Charles Kerr 71ad42b1ef
refactor: make err arg optional in tr_sys_* funcs (#2827) 2022-03-27 12:37:29 -05:00
Charles Kerr 977b2a1bab
refactor: tr_loadFile() tr_saveFile() take a std::string_view filename arg (#2822)
* refactor: tr_saveFile takes a string_view

* refactor: tr_saveFile, tr_loadFile take string_view filename
2022-03-25 19:31:27 -05:00
Charles Kerr 1051160b99
feat: strbuf features (#2821)
* feat: strbuf is always zero-terminated

* feat: tr_strbuf::append() now takes any number of args

* feat: tr_strbuf handles zero-terminated string inputs

* feat: add tr_strbuf::ends_with()

* feat: add tr_strbuf::starts_with()

* refactor: replace buildPath() with join()
2022-03-25 16:16:26 -05:00
Charles Kerr bd895b5052
test: fix file-info test edge case (#2811) 2022-03-24 19:03:15 -05:00
Charles Kerr 6e8f9f3ff0
feat: add tr_strbuf (#2810)
* feat: add tr_strbuf class for building tmp strings

Based on fmt::basic_memory_buf, this is a growable string buffer that
has an initial size that's large enough to build most filenames or URLs
without needing heap allocations.

Adds a couple of extra helpers such as a `c_str()` method to make dealing
with old zero-terminated string APIs easier.
2022-03-24 16:41:29 -05:00
Charles Kerr 03ee0028d4
refactor: tr_sys_path_dirname returns a std::string (#2792) 2022-03-21 15:22:50 -05:00
Charles Kerr fcc1510ecb
refactor: use fmt to build the GTK client's user-visible strings (#2788)
Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-03-21 09:15:48 -05:00