Commit Graph

4777 Commits

Author SHA1 Message Date
Mike Gelfand 139f3a3f4b Add missing declaration for `tr_strcasestr` 2019-06-23 12:07:33 +03:00
Mike Gelfand f3968b7708 Load CA certs from system store on Windows / OpenSSL
Fixes: #446
2019-06-23 11:59:53 +03:00
LaserEyess 750589101a Parse session-id header case-insensitively (#765)
RFC 2616 defines headers as case-insensitive, so if rpc is behind a
reverse proxy that lowers the case of headers, transmission will not
parse them correctly.

A new wrapper function, `tr_strcasestr` is added to
libtransmission/utils.c to allow for comparisons of headers case
insensitively, and checks in cmake and autogen are included.
2019-03-17 17:37:52 +03:00
Mike Gelfand 5693e59256 Define each identifier in a dedicated statement
* MISRA C++:2008, 8-0-1 - An init-declarator-list or a member-declarator-list
  shall consist of a single init-declarator or member-declarator respectively
* CERT, DCL52-J. - Do not declare more than one variable per declaration
* CERT, DCL04-C. - Do not declare more than one variable per declaration
2019-03-17 09:15:35 +03:00
Mike Gelfand 97a0fed734 Remove side effects from right hand operands of && or ||
* MISRA C:2004, 12.4 - The right-hand operand of a logical && or || operator
  shall not contain side effects.
* MISRA C++:2008, 5-14-1 - The right hand operand of a logical && or ||
  operator shall not contain side effects.
* MISRA C:2012, 13.5 - The right hand operand of a logical && or || operator
  shall not contain persistent side effects
* CERT, EXP02-C. - Be aware of the short-circuit behavior of the logical AND
  and OR operators
2019-03-17 09:09:08 +03:00
Mike Gelfand 17307e7484 Extract assignments from expression
Assignments explicitly enclosed in parentheses are ignored.

* MISRA C:2004, 13.1 - Assignment operators shall not be used in expressions
  that yield a Boolean value
* MISRA C++:2008, 6-2-1 - Assignment operators shall not be used in
  sub-expressions
* MISRA C:2012, 13.4 - The result of an assignment operator should not be used
* MITRE, CWE-481 - Assigning instead of Comparing
* CERT, EXP45-C. - Do not perform assignments in selection statements
* CERT, EXP51-J. - Do not perform assignments in conditional expressions
2019-03-17 08:00:15 +03:00
Mike Gelfand d3b8982195 Uppercase the literal suffixes
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a
  literal suffix
* CERT DCL16-C. - Use "L," not "l," to indicate a long value
* CERT, DCL50-J. - Use visually distinct identifiers
2019-03-17 07:07:48 +03:00
Mike Gelfand 698bb2c418 Attempt to explain something to Coverity
I'm seeing 7 potentially false reported issues re. use of uninitialized buffer
data here. It seems that `read` function should be properly supported by
Coverity, but maybe it can't figure out the postconditions of it properly...
Walking in the dark here.
2019-03-13 05:32:35 +03:00
Mike Gelfand 10b0a280b1 Let compiler calculate static quark lenghts for us 2019-03-13 00:01:17 +03:00
Mike Gelfand 1442f8fded Fix build break from previous commit on old Clangs
Remove static assert altogether: it should have worked everywhere anyway,
otherwise there is no point.

Add a few casts here and there to ensure proper type for directory handle.
2019-03-10 19:52:27 +03:00
Mike Gelfand 36110e18c4 Fix build on E2K with LCC (patch by Michael Shigorin, ALT Linux) 2019-03-10 19:35:10 +03:00
Charles Kerr 309d97c578
fix: Coverity warnings (#842)
* Silence coverity CHECKED_RETURN on added.f load

The existing code behaved alright since added.f is optional.
However, by testing for success we can both silence the warning
and prevent a useless initialization of NULL/0 to added_f and
added_f_length.

* Silence coverity CHECKED_RETURN on added6.f load

ipv6 variant of previous commit.

* Silence coverity CHECKED_RETURN writing benc strs

saveStringFunc() gets the target string by calling tr_variantGetStr().
It previously didn't check to see if this function succeeded because
saveStringFunc() isn't reached without the type already being known.
However, checking the return value costs nothing and makes Coverity happy.

* Silence coverity CHECKED_RETURN on ut metadata

Like earlier few Coverity commits in this PR, we're handling optional
values by declaring stack locals set to the default (e.g. -1) and then
trying to read the variant.

Unlike the earlier commits, there is a two-part step to thise read:
checking for the metadata, then checking for the individual fields.
The earlier fixes' aproach -- e.g. initializing to -1 only if the reads
failed -- would involve new nested conditionals. I find the new complexity
to outweigh the benefit of removing the dead store, so in this case I'm
casting the return value to `(void)` to tell Coverity to shush.

* Silence coverity CHECKED_RETURN on scrape

Check the return value of tr_variantGetInt() when showing
seeder and leecher counts in transmission-show.

* Silence CHECKED_RETURN on rpc recently-active

When building a list of removed torrent IDs from variants, confirm that
we can read the IDs from the variants before adding them to the list.
I don't _think_ this would have failed before, but Coverity's right that
it's reasonable to add a safeguard here.

* fix: better fix to serializing benc strings

The approach in 33e2ece7e5 was
a little problematic: GetString() shouldn't fail here; but if
it somehow did, we still want to encode a zero-length benc string here.

* chore: make uncrustify happy
2019-02-18 22:38:24 +00:00
qu1ck 7aa12a025d Add labels feature (#822)
* applied changes from https://github.com/Elbandi/transmission/tree/elbandi/labels to official transmission repo

* Fix compilation errors

* Address review comments

Changed `tr_ptrArray* labels` to `tr_ptrArray labels`;
Removed tr_ptrArrayNew() tr_ptrArrayDup() tr_ptrArrayFree()
Use tr_strsep() to split string by delimiters
Update transmission-remote.1
Update rpc-spec.txt

* Fix warning, address comments

* Rebase, fix formatting and address comments

Use uncrustify to format changed files
Fix "const <type>" -> "<type> const"
Fix small comments

* Lock torrent for setLabels, check for duplicates

* Check for empty labels in daemon

* Stop on first error
2019-02-17 04:33:57 -05:00
Charles Kerr 2013772aad
feat: make multiscrape limits adaptive (#837)
* feat: make multiscrape limits adaptive

Previously hardcoded by TR_MULTISCRAPE_MAX. This change makes
that the initial value, then incrementally lowers the value
when multiscrapes get "req too long" style errors.

* fix: don't log personal announce url

* chore: treat HTTP 400 as scrape-too-long

* chore: copyediting

* chore: copyediting

* move 'const' to the right of the type

* make conditional tests explicitly boolean

* make 'key' const

* don't lookup a value we already have

* make an array for known too-big scrape error messages

* improved multiscrape throttle logging

* fix: multiscraping of low numbers of torrents

Handle the case of getting a 'multiscrape too big' error message
back even if the user fewer than TR_MULTISCRAPE_MAX torrents.

* uncrustify

* fix oops

* refactor: remove TR_MULTISCRAPE_MIN

Is there any reason to have a minimum batch size?

* make test explicit boolean

Co-Authored-By: ckerr <ckerr@github.com>

* improve declaration of too_long_errors

Co-Authored-By: ckerr <ckerr@github.com>

* make test explicitly boolean

Co-Authored-By: ckerr <ckerr@github.com>

* make test explicitly boolean

Co-Authored-By: ckerr <ckerr@github.com>

* improve looping decl of too_long_errors
2019-02-16 15:19:38 -05:00
Mike Gelfand 1d6d946388 Fixup some formatting leftovers 2019-02-16 10:50:37 +03:00
Mike Gelfand 82df3a87f4 Update to Uncrustify 0.68.1
Tweak a few rules in the process. Now all code in cli, daemon, gtk,
libtransmission, qt, and utils is properly formatted with no manual
intervention.
2019-02-15 09:21:48 +03:00
Charles Kerr 39d1a54fbd
Merge branch 'master' into update-resume-file-before-invoking-torrent-scripts 2019-02-06 02:00:47 -05:00
Charles Kerr 5082393d92 address dirty/save sequencing issue in prev commit 2019-02-02 14:49:53 -06:00
Charles Kerr b04f2df299
Merge pull request #741 from Artoria2e5/parseline-cidr
Support CIDR-notated blocklists
2019-02-01 23:38:48 -06:00
Charles Kerr 08f5a0fdaa fix: update the resume file before running scripts
This is useful if the client script is going to access
the .resume file. Ensuring an up-to-date .resume file
means that user scripts will be able to access it.
2019-02-01 21:59:17 -06:00
Peter Dave Hello 7a0d2e63c7 Refactor shell scripts with syntax and styling fixes 2019-01-16 03:22:29 +08:00
Mingye Wang 847b43ffd3 (squash later) test rule count 2018-10-17 10:26:05 -04:00
Mingye Wang 94ee776113 (squash later) blocklist cidr endianness 2018-10-17 09:41:19 -04:00
Mingye Wang f61306f65f (squash later) fix pflen handling in cidr 2018-10-14 12:44:01 -04:00
Mingye Wang b3129591db Support CIDR-notated blocklists
This commit adds a new blocklist line format, namely individual IPv4
CIDR ranges separated by newlines. Text put after each entry is ignored
by sscanf, so feel free to put any kind of comments there.

Fix #230.
2018-10-13 17:23:45 -04:00
Mike Gelfand a53bae2849 Fix file-test on Win32 due to file/dir symlinks difference 2018-09-04 01:06:21 +03:00
Mike Gelfand c951848a5b Merge branch '2.9x' 2018-05-01 22:44:51 +03:00
userwithuid 873006c373 fix logic for setting the curl ca bundle file
we do not want to delete the system default by setting this to NULL...
2018-04-25 08:21:50 +00:00
Mike Gelfand 69d9afd75a Adjust CFBundleVersion format to fix Sparkle update check
Set the first version component to be the same as the last Subversion-based
release build version and add two more components (major and minor version
numbers). To allow for nightly build updates this should probably include
another component (e.g. build timestamp), but we're not there yet.
2018-04-17 13:25:49 +03:00
geertjan cc0b931431 Fix setting the ETA timestamps
Field etaDLSpeedCalculatedAt was set too early, causing the condition
following it to always be false. The same for etaULSpeedCalculatedAt.
2018-04-06 22:52:29 +03:00
Mike Gelfand 444f15edf8
Merge pull request #522 from gjalsem/master
Fix setting the ETA timestamps
2018-04-06 22:49:27 +03:00
Mike Gelfand ab4d707305
Merge pull request #528 from neheb/patches
Fix compile errors for 2.9x
2018-04-06 22:34:11 +03:00
Bernard Spil 06a1644e29 Fix build with LibreSSL 2.7
LibreSSL 2.7 adds OpenSSL 1.1 API

See also: https://bugs.freebsd.org/226953
Signed-off-by: Bernard Spil <brnrd@FreeBSD.org>
2018-04-06 22:17:41 +03:00
Niklas Haas 11d29ff62d LibreSSL compatibility
This seems to be the idiomatic way to fix libressl compatibility issues,
judging by what most other open source projects seem to be doing.

I've confirmed that transmission builds with libressl for me after this
patch is applied.
2018-04-06 22:16:26 +03:00
Mike Gelfand 9d96f87ec3 Fix coding style and building with !TR_LIGHTWEIGHT 2018-04-06 22:15:22 +03:00
Bernard Spil bdffe25b42 Fix build with LibreSSL 2.7
LibreSSL 2.7 adds OpenSSL 1.1 API

See also: https://bugs.freebsd.org/226953
Signed-off-by: Bernard Spil <brnrd@FreeBSD.org>
2018-04-01 22:39:09 +02:00
Mike Gelfand 4d5fe6ede9 Add support for mbedtls (formely polarssl) 2018-02-23 20:46:39 -08:00
geertjan 23e469a6b2 Fix setting the ETA timestamps
Field etaDLSpeedCalculatedAt was set too early, causing the condition
following it to always be false. The same for etaULSpeedCalculatedAt.
2018-02-19 21:06:34 +01:00
Mike Gelfand 96926a8337 Update DHT library to 0.25
Fixes: #508
2018-02-10 11:35:14 +03:00
Rosen Penev a3ef28bd68 Set compression to curl defaults
While zlib is mandatory for transmission, it is not mandatory for curl.

A libcurl that has been compiled with no support for zlib will return no data if compressed responses are set to on.

In the basic case this prevents the port checking functionality from working properly. It also prevents web seeding from working as well.
2018-01-31 20:59:01 -08:00
Mike Gelfand 94be7dbd9b Merge branch '2.9x' 2018-01-25 03:07:52 +03:00
Mike Gelfand 4b6529d883 Don't crash if path passed to tr-create doesn't exist 2018-01-24 23:45:13 +03:00
Mike Gelfand 3106675261 Fix UNC paths resolution on Windows
While resolved paths always contain the	`\\?\` prefix, it's not	always
correct	to strip only those 4 chars. In	case of	UNC paths, the prefix
is actually a bit longer (`\\?\UNC\`) and needs	to be replaced with `\\`
instead.

Failing	to do so results in invalid paths, e.g.	`\\Host\Share\File` becomes
`UNC\Host\Share\File` which totally wrong.
2018-01-24 23:45:08 +03:00
Mike Gelfand 6da6629887 Add unit tests uncovering improper UNC paths resolution
While resolved paths always contain the `\\?\` prefix, it's not always
correct to strip only those 4 chars. In case of UNC paths, the prefix
is actually a bit longer (`\\?\UNC\`) and needs to be replaced with `\\`
instead.

Failing to do so results in invalid paths, e.g. `\\Host\Share\File` becomes
`UNC\Host\Share\File` which totally wrong.
2018-01-24 23:12:17 +03:00
Mike Gelfand 7f008edab6 Improve version.h file generation
Store full revision hash in REVISION file. Write fixes 10 chars of revision
hash to version.h. Use `#pragma once` in version.h. Support getting revision
from TeamCity environment variable (similar to Jenkins).
2018-01-23 21:59:09 +03:00
Mike Gelfand b875e79f3d Replace SVN and SCM with VCS everywhere 2018-01-23 21:58:33 +03:00
Mike Gelfand 99c9b90965 Fix memory leak in `tr_dhtInit` in failure condition
Fixes: #482
2018-01-23 21:20:30 +03:00
Sebastian Andrzej Siewior 22bde650ea transmission: build against openssl 1.1.0
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2018-01-19 02:44:12 +03:00
Mike Gelfand c0c2ba0b13 Make host validation not depend on CSRF being enabled (see #468) 2018-01-17 23:38:12 +03:00
Mike Gelfand 90686f30ce Support IPv6 addresses when whitelisting hosts (see #468) 2018-01-17 23:32:14 +03:00
Mike Gelfand c22e687b51 Simplify `tr_ssha1_matches` logic
Gets rid of needless heap memory allocations and copying. Convert SHA1 hash
to hex in-place.

Fixes: #141
2018-01-17 01:17:50 +03:00
Mike Gelfand 1d04ea65d3 Don't switch trackers while announcing
Fixes: #297
2018-01-17 01:09:07 +03:00
Mike Gelfand aa2730d47c Switch to HTTPS links, adjust wiki links where possible
Fixes #39
2018-01-16 01:12:59 +03:00
Tavis Ormandy 440f03e9ad mitigate dns rebinding attacks against daemon 2018-01-16 01:12:56 +03:00
Mike Gelfand 7cc4cfbe7b Abort handshake if establishing DH shared secret fails
Fixes #27
2018-01-15 23:51:44 +03:00
Tavis Ormandy cf7173df93 mitigate dns rebinding attacks against daemon 2018-01-15 23:31:25 +03:00
Mike Gelfand ffcca3964d Adjust test names in CMake to be in line with autoconf ones 2017-12-02 17:58:15 +03:00
Mike Gelfand fae6b40002 Fix memory leaks in subprocess test 2017-12-02 17:57:11 +03:00
Mike Gelfand 30c7c05cbb Refactor completion scripts execution
There're still a few issues here and there, but overall I believe it's now
better than it was before.
2017-11-28 10:03:08 +03:00
Mike Gelfand 5b29fe1556 Ensure include guard is the first non-comment line 2017-11-14 23:21:28 +03:00
Mike Gelfand ede21744d3 Fix potential NULL pointer dereference introduced by last commit 2017-10-31 10:01:06 +03:00
Mike Gelfand 474aabbbc4 Take another approach to creating intermediate dirs on *NIX
Walk up one level at a time until the directory creation succeeds, then go
back down one level at a time. This reduces the number of operations in the
most common case (when directory already exists).
2017-10-30 10:23:18 +03:00
Dhiru Kholia 874df139e1 Add Peer ID for Baidu Netdisk
Baidu Netdisk uses Azureus-style Peer ID with "-BN" prefix.
2017-08-26 11:11:31 +05:30
bobbyhopere cb6047ba3c All modifications suggested by mikedld 2017-08-13 13:53:41 +02:00
bobbyhopere 5f25e3be7f anti-brute force for RPC Server 2017-08-12 16:36:43 +02:00
Mike Gelfand 6410a460ea Merge pull request #360 from clyang/master
Improving ToS on IPv6 connections
2017-08-08 18:32:44 +03:00
Dhiru Kholia e1c8ec41f8 Add Peer ID for Folx
Based on experiments with Folx version 5.2.1.13690 running on macOS
Sierra.

Folx uses Azureus-style Peer ID with "-FL" prefix.
2017-08-05 12:29:16 +05:30
clyang 81c9653383 Improve ToS on IPv6 connections 2017-08-03 06:30:54 +03:00
Dhiru Kholia 8c87a58cdd Add Peer ID for Free Download Manager (FDM)
Based on experiments with FDM 5.1.32 running on Windows 10.

FDM uses Azureus-style Peer ID with "-FD" prefix.
2017-08-02 20:33:41 +05:30
Mike Gelfand bb4741002f Go back to using hash as base name for resume and torrent files
The format introduced in TRAC-394 is nice but brings its own issues (e.g.
TRAC-4189, #122). I'm okay with a bit of grepping myself if it makes the
experience better for end users.

Using hashes results in filenames well under 255 bytes limit on some
filesystems. If even that will not be enough, I'd suggest reporting the
issue elsewhere.

Fixes: #122
2017-07-26 21:32:26 +03:00
Mike Gelfand 55b41c9015 Patch up file test to allow for a bit of time discrepancy
Since one cannot really compare system time to filesystem time (see e.g.
https://lkml.org/lkml/2017/3/30/809), allow for 1 second error to avoid
(or at least minimize) random test failures.
2017-07-21 00:45:30 +03:00
Simon Wells 44411d719c Change TR_CURL_SSL_VERIFY to TR_CURL_SSL_NO_VERIFY
use secure by default and change the env var to match curl -k behaviour

Closes: #179
2017-07-16 20:48:44 +03:00
Mike Gelfand 580c5e4166 Rename `tr_sys_file_prefetch` to `tr_sys_file_advise`
New function now supports two flags: will need and don't need.
2017-07-08 16:09:37 +03:00
Mike Gelfand 28c872af1e Change `tr_sys_file_prefetch` behavior a bit
Return true by default. Only return false if we did in fact perform some
action and it failed.
2017-07-08 12:51:36 +03:00
Mike Gelfand 8c88e8bba0 Change torrent location even if no data move is needed
This helps when old and new location point to the same place but the actual
path differs (i.e. one of the paths is a symlink).

Fixes: #35
2017-07-06 21:46:32 +03:00
Mike Gelfand a86266d3c2 Don't switch trackers while announcing
Fixes: #297
2017-07-04 21:22:26 +03:00
Mike Gelfand d46fdda9ea Correct "annouce" spelling
Fixes: #303
2017-07-02 19:18:02 +03:00
Mike Gelfand 27b6884408 Move uTP timer to session struct 2017-07-02 13:31:33 +03:00
Mike Gelfand 87c9596305 Fix a couple more implicit boolean expressions 2017-07-02 13:26:26 +03:00
Mike Gelfand 18aabdeb06 Introduce peer socket struct to improve readability 2017-06-28 18:50:05 +03:00
Mike Gelfand 74548e01b6 Remove obsolete comment as we're using C99 now 2017-06-28 18:50:05 +03:00
Mike Gelfand 13bbaeec76 Use field initializers for readability 2017-06-24 13:30:33 +03:00
Aleksej Lebedev b7b1d2475e Fixed platform-quota.c for DragonFly. The patch is taken from dports. 2017-06-19 19:27:05 +03:00
Mike Gelfand f701d501a8 Move generic macros to a separate tr-macros.h file 2017-06-18 17:11:20 +03:00
Mike Gelfand deea6fc6a2 Bring assertions closer to the beginning of blocks 2017-06-13 07:44:09 +03:00
Mike Gelfand 98695fe3c1 Introduce our own assertion macros with finer control 2017-06-08 10:24:12 +03:00
Mike Gelfand 5f7bc801c8 Make use of new checking capabilities in unit tests 2017-05-30 20:56:12 +03:00
Mike Gelfand 3d0b06ca0f Add generic `check_mem` (libtest) 2017-05-30 20:09:19 +03:00
Mike Gelfand 2a7cf67913 Add generic `check_bool`, extend `check` to be more informative (libtest) 2017-05-30 19:21:14 +03:00
Mike Gelfand b1b5a577cf Transform `check_ptr_eq` into generic `check_ptr` (libtest) 2017-05-30 17:51:50 +03:00
Mike Gelfand 437904198e Transform `check_uint_eq` into generic `check_uint` (libtest) 2017-05-30 17:51:50 +03:00
Mike Gelfand 9c3c6f11e0 Transform `check_int_eq` into generic `check_int` (libtest) 2017-05-30 17:51:50 +03:00
Mike Gelfand 14c30119d4 Transform `check_str_eq` into generic `check_str` (libtest) 2017-05-30 17:51:46 +03:00
Mike Gelfand 341b778099 Continue running other test-cases even if one fails (libtest) 2017-05-30 17:44:51 +03:00
Mike Gelfand c071f824ec Pass `(u)intmax_t` instead of `(u)int64_t` to `check_(u)int_eq` (libtest) 2017-05-30 17:44:47 +03:00
Mike Gelfand 7a238e7c65 Rename `check_streq` to `check_str_eq` to be in line with other macros (libtest) 2017-05-30 17:44:42 +03:00
Mike Gelfand 432d573f2c Fixup 2321bc3fad (unintended logic change, spotted by cfpp2p in #297) 2017-05-29 08:50:40 +03:00
Mike Gelfand f27596238d Include stdbool.h unconditionally
All the compilers should provide the header file by now. Remove `tr_isBool`
sanity checks along the way as compiler should guarantee that bool (_Bool)
values are 0 or 1 and nothing else.
2017-05-24 22:53:06 +03:00
Mike Gelfand 295d3359b2 Little bastards keep popping up here and there :( 2017-05-23 22:17:17 +03:00
Mike Gelfand 501be27972 Reduce code duplication in logging macros 2017-05-22 23:20:28 +03:00
Dhiru Kholia dda33afbe0 Add Peer ID for PicoTorrent
Based on information from https://github.com/picotorrent/picotorrent and
http://www.picotorrent.org/.

PicoTorrent uses Azureus-style peer ID: -PI-. Example: -PI0091- (major:
0, minor: 09, patch: 1).
2017-05-21 12:30:47 +05:30
Mike Gelfand 82722476aa Fix some issues reported by Coverity 2017-05-20 23:31:56 +03:00
Mike Gelfand 8f3cb1c68d Wrap sizeof arguments in braces 2017-05-20 19:29:23 +03:00
Mike Gelfand 6303bb2247 Disable part of mmap test on OpenBSD that depends on UBC 2017-05-20 13:34:23 +03:00
Niklas Haas 4d7446e477
LibreSSL compatibility
This seems to be the idiomatic way to fix libressl compatibility issues,
judging by what most other open source projects seem to be doing.

I've confirmed that transmission builds with libressl for me after this
patch is applied.
2017-05-20 07:16:53 +02:00
Mike Gelfand 6b0229a546 Fix some issues reported by Coverity 2017-05-16 21:37:00 +03:00
Mike Gelfand 1e3d20422a Reduce for loop variables scope 2017-05-14 01:38:31 +03:00
Mike Gelfand 6d5e48f9e2 Fix some more off-by-one errors on last piece
See: TRAC-4037 and e2584b04ff
2017-05-09 14:23:25 +03:00
Piotr Drąg ccabc01900 lib: fix translator comment extraction
gettext won’t pick up a comment if it’s
not exactly one line above the string.
2017-05-02 21:22:15 +02:00
Mike Gelfand 87220d44a5 Fix FTBFS on Windows (oops!) 2017-05-01 19:08:30 +03:00
Mike Gelfand 14370e5353 Fix a number of other style inconsistencies met along the way (part 2) 2017-05-01 18:47:49 +03:00
Mike Gelfand e1d53855f4 Avoid declaring multiple variables on the same line 2017-05-01 18:46:41 +03:00
Mike Gelfand 1bc247c105 Merge pull request #161 from slokhorst/rpc-ipv6
Allow the RPC server to listen on an IPv6 address
2017-05-01 13:31:14 +03:00
Mike Gelfand 6a74bd438c Announce INT64_MAX as size left if the value is unknown
This helps with trakers like Amazon S3 where signed type is used but
negative values aren't accepted.

Fixes: #250
2017-05-01 12:33:55 +03:00
Mike Gelfand ac4fa04277 Announce -1 as size left if the value is unknown
Fixes: #250
2017-04-30 21:18:02 +03:00
Mike Gelfand efaa9d0ddc Compare system function return value to a specific value indicating the error 2017-04-30 19:47:18 +03:00
Mike Gelfand b342d134cb Merge pull request #256 from kholia/Xfplay
Add Peer ID for Xfplay torrent client
2017-04-30 19:43:49 +03:00
Mike Gelfand fbd8d4c79f Fix a number of other style inconsistencies met along the way 2017-04-30 19:33:55 +03:00
Mike Gelfand a762c770f2 Make conditional expressions explicitly boolean 2017-04-30 19:26:01 +03:00
Dhiru Kholia e970d7e546 Add Peer ID for Xfplay torrent client
This is based on the following resources,

http://www.xfplay.com/history.html
https://down.xfplay.com/xfplay9.994.exe
https://down.xfplay.com/xfplay9.992.exe
https://down.xfplay.com/xfplay9.991.exe
https://down.xfplay.com/xfplay9.99.exe
http://q.xfplay.com/
2017-04-29 12:40:55 +05:30
Sebastiaan Lokhorst ac661ff099 Allow the RPC server to listen on an IPv6 address 2017-04-26 17:46:36 +02:00
Mike Gelfand 6a15bc6742 Fix mount points enumeration (platform quota) on Solaris
Per documentation, `getmntent` returns 0 on success and -1 on error.
2017-04-22 21:42:44 +03:00
Mike Gelfand 4f9d9ad92b Code style change leftovers
For some reason, GTK client wasn't fully processed. All the rest of changes
are mostly in comments.
2017-04-21 10:40:57 +03:00
Mike Gelfand dadffa2c0f Align type qualifiers to the right (code style)
This way all the qualifiers (`const`, `volatile`, `mutable`) are grouped
together, e.g. `T const* const x` vs. `const T* const x`. Also helps reading
types right-to-left, e.g. "constant pointer to constant T" vs. "constant
pointer to T which is constant".
2017-04-20 19:53:20 +03:00
Mike Gelfand d7930984ef Adjust uncrustify config, reformat all but Mac client
There're places where manual intervention is still required as uncrustify
is not ideal (unfortunately), but at least one may rely on it to do the
right thing most of the time (e.g. when sending in a patch).

The style itself is quite different from what we had before but making it
uniform across all the codebase is the key. I also hope that it'll make the
code more readable (YMMV) and less sensitive to further changes.
2017-04-20 10:01:22 +03:00
Mike Gelfand 0f75e64d71 Detach the thread from within itself to avoid race condition
Fixes: #188
2017-02-23 00:07:39 +03:00
neheb 944382a62e Add TCP_FASTOPEN support
Should make transmission slightly faster.
2017-02-19 12:54:01 +03:00
Edward Betts 9e1c76a50f fix spelling mistake 2017-02-01 10:14:11 +00:00
Mike Gelfand 1cc67b31dd Use PRIdMAX instead of TR_PRI_SOCK to accomodate intltool 2017-01-27 04:50:14 +03:00
Mike Gelfand c1f08edf79 Fix memory leaks found by GCC's -address=sanitize (reported by milloni)
Fixes: #56
2017-01-17 23:55:34 +03:00
Mike Gelfand 67bda2dcb8 Handle two more cases where dirname/basename may have returned NULL (adds to 91f8ceb20d) 2017-01-17 02:22:31 +03:00
Mike Gelfand fd93316466 Improve version.h file generation
Store full revision hash in REVISION file. Write fixes 10 chars of revision
hash to version.h. Use `#pragma once` in version.h. Support getting revision
from TeamCity environment variable (similar to Jenkins).
2017-01-15 00:54:56 +03:00
Mike Gelfand 3375b22b23 Simplify `tr_ssha1_matches` logic
Gets rid of needless heap memory allocations and copying. Convert SHA1 hash
to hex in-place.

Fixes: #141
2017-01-09 14:15:07 +03:00
Mike Gelfand 15625de3c7 Extend SSHA1 test to check for predefined matches
Reduce number of test iterations to 4K along the way to shorten execution
time.
2017-01-09 14:12:17 +03:00
Mike Gelfand 4179a623d5 Interrupt verification ASAP if torrent is being removed 2016-12-31 14:23:06 +03:00
Mike Gelfand 0ac657c5f1 Fix up rename test to avoid random use-after-free failures 2016-12-25 19:44:38 +03:00
Mike Gelfand 3cda09ea81 Fix up rename test to avoid random duplicate torrent failures 2016-12-24 21:24:50 +03:00
Mike Gelfand 88505c345f Allow for different-cased "nan" value returned by tr_truncd 2016-12-24 20:20:55 +03:00
Mike Gelfand 448d8f39f6 CMake support for Solaris 2016-12-24 20:16:54 +03:00
Mike Gelfand 193d68cc5c Move tr_metainfoFree call higher per review comment 2016-12-09 22:01:58 +03:00
seiyap70 8541d74793 free the info resource if failed
free the info resource if failed
2016-11-07 14:07:56 +08:00
Mike Gelfand d8dd6f9c75 Merge pull request #60 from milloni/strncmp-instead-of-memcmp
Use strncmp instead of memcmp to avoid out-of-bounds reads
2016-11-02 23:13:25 +03:00
Markus Amalthea Magnuson 5b9ba3be0d HTTPS links for trac, forum, portcheck, and build subdomains. 2016-11-02 20:50:22 +01:00
Mike Gelfand 71af7be04f Improve support for wolfssl (formely cyassl) 2016-10-26 22:27:20 +03:00
Mike Gelfand 7f94c8df6c Add support for mbedtls (formely polarssl) 2016-10-26 22:27:20 +03:00
Maciej Wolny 69c33d0e18 Fix signedness related warnings 2016-10-20 20:27:55 +02:00
Maciej Wolny c6ad5bd36c Go back to using memcmp in libtransmission/net.c 2016-10-20 17:35:46 +02:00
Mike Gelfand 0390684bc4 Merge pull request #42 from wbx-github/master
uClibc-ng since 1.0.18 has sys/quota.h synced with GNU libc
2016-10-19 21:01:06 +03:00
Waldemar Brodkorb bae138ca22 uClibc-ng since 1.0.18 has sys/quota.h synced with GNU libc 2016-10-19 19:33:35 +02:00
Mike Gelfand eda26f7590 Make sure `tr_sha1` calls pass lengths as int
This fixes inability to authenticate with password-protected session, and
a few more issues it seems.
2016-10-18 00:05:03 +03:00
Maciej Wolny 3a1730495d Use strncmp instead of memcmp to avoid out-of-bounds reads 2016-10-05 16:19:31 +02:00
Mike Gelfand 17fb783c50 Add session-id.{c,h} to autoconf and Xcode builds 2016-09-27 21:36:01 +03:00
Mike Gelfand 661e2b513d Return session ID as part of "session-get" response 2016-09-27 21:18:36 +03:00
Mike Gelfand ff73e65069 Handle "fields" argument in "session-get" RPC request
If "fields" array is present in arguments, only return session fields
specified. Otherwise return all the fields as before.
2016-09-27 21:18:32 +03:00
Mike Gelfand b82f6009dd Maintain lock file(s) corresponding to session ID 2016-09-27 20:53:10 +03:00
Mike Gelfand 26b0a041cc Factor out session ID into a standalone entity 2016-09-21 22:29:56 +03:00
Mike Gelfand 4c00df9463 Abort handshake if establishing DH shared secret fails
Fixes #27
2016-09-18 14:01:00 +03:00
Mike Gelfand 8c8386a7f3 Fix coding style and building with !TR_LIGHTWEIGHT 2016-09-07 01:09:04 +03:00
Sebastian Andrzej Siewior f91cf5ad8c transmission: build against openssl 1.1.0
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
2016-09-06 00:11:17 +02:00
Mike Gelfand 2248d3670f Get rid of $Id$ SVN keywords in source files 2016-09-02 23:10:15 +03:00
Mike Gelfand 1b81bb7682 Replace SVN and SCM with VCS everywhere 2016-09-02 22:21:00 +03:00
Mike Gelfand 076fd29098 #6071: Fix typo in comment 2016-04-23 16:21:39 +00:00
Jordan Lee 7cd2d10d00 crypto.h and crypto-utils.h can't use #pragma once, it breaks our name munging in crypto-test-ref.h 2016-03-29 19:02:26 +00:00
Jordan Lee c1abfe87c8 maybe fix double-include of crypto.h / crypto-utils.h in crypto-test 2016-03-29 17:18:50 +00:00
Jordan Lee 1af60ad6ad use '#pragma once' instead of #ifndef..#define..#endif guards 2016-03-29 16:37:21 +00:00
Jordan Lee 77b5105ea0 fix bad TR_DEPRECATED macro on clang :P 2016-03-29 16:01:41 +00:00
Jordan Lee 8d38442cc1 give a useful definition of TR_DEPRECATED on msvc as well 2016-03-29 15:47:29 +00:00
Jordan Lee 5fbd24fda5 fix a handful of minor compiler warnings, mostly in the unit tests, eg field width shortening or implicit signed/unsigned conversions 2016-03-29 03:04:54 +00:00
Mike Gelfand c955c04d8f Explicitly compare result of str(n)cmp/memcmp to signify that it's not boolean 2016-03-13 22:11:01 +00:00
Mike Gelfand 91f8ceb20d Handle potential dirname/basename errors where needed 2016-03-13 10:41:52 +00:00
Mike Gelfand 86f231184b Fix warning for when 2nd `iconv()` argument is const 2016-02-23 05:07:43 +00:00
Mike Gelfand 990dea4dd3 Only depend on iconv if found 2016-02-07 12:00:15 +00:00
Mike Gelfand 96ea2c82fd Check for `iconv()` instead of `iconv_open()`, adjust utils test 2016-02-07 11:54:01 +00:00
Mike Gelfand a447f0d628 #6064: Add test cases which exhibit the issue 2016-02-06 22:23:36 +00:00
Mike Gelfand 1eb0ae0a3a #6064: Merge ConvertUTF.c fixes from LLVM (?) 2016-02-06 22:05:22 +00:00
Mike Gelfand 9e7293b710 Add hidden "watch-dir-force-generic" setting handling to daemon 2016-01-25 22:09:49 +00:00
Mike Gelfand 39749f8e4b Make it possible to force generic watchdir implementation in runtime 2016-01-25 21:48:58 +00:00
Mike Gelfand 0e7a8eb7aa Add bitfield test for has all/none 2016-01-08 11:12:22 +00:00
Mike Gelfand 13a98a02b8 Use `TR_BAD_SIZE` instead of -1 in `tr_quark_new()` calls
Extend quark test to improve branch coverage.
2016-01-07 19:20:14 +00:00
Mike Gelfand bfbf81cea1 #6048: Improve error checking on metadata retrieval 2016-01-07 17:12:14 +00:00
Mike Gelfand eb49800fab #5737: Retry if RPC server fails to bind to specified address 2016-01-07 15:28:58 +00:00
Mike Gelfand 53c38c760d Add tests in such a way that target name is expanded (CMake) 2016-01-04 19:50:32 +00:00
Mike Gelfand 4a634ae026 #5663: Autotools fixes: proper kqueue check, macro definitions 2016-01-04 19:14:38 +00:00
Mike Gelfand 9ecd2ad319 Improve file test modification time checks 2016-01-04 05:04:55 +00:00
Mike Gelfand 6e00b1c543 Uncomment error prefixing tests 2016-01-03 21:03:54 +00:00
Mike Gelfand 52b2a7557f Fix line endings on last commit 2016-01-02 15:26:23 +00:00
Mike Gelfand 119d10f01e #5663: Emulate `GetOverlappedResultEx` on Windows Vista/7 2016-01-02 15:23:38 +00:00
Mike Gelfand ea48360212 #5663: Rework directory watching in daemon
Implement BSD/Darwin (kqueue) and Windows (ReadDirectoryChanges) mechanisms
for receiving directory change notifications. Use events instead of polling
for changes. Retry file parsing up to 3 times before giving up.

Huge thanks to missionsix for preparing first two versions of the patch.
2016-01-02 14:28:59 +00:00
Mike Gelfand de304e8a35 #5407: In `tr_peerMgrGetDesiredAvailable()`, check if swarm is running (suggested by x190) 2015-12-31 14:33:02 +00:00
Mike Gelfand 7d30ad3ff6 #5891: Move UDP shutdown timer setup to sessionCloseImplStart 2015-12-31 14:24:15 +00:00
Mike Gelfand d3f5b5d5ab #5891: Fix crash on session shutdown (evdns_getaddrinfo_cancel) 2015-12-31 14:17:37 +00:00
Mike Gelfand 40f3de0572 Loosen bitfield assertions to account for unknown bit counts 2015-12-31 05:22:42 +00:00
Mike Gelfand d4213f09d5 On second thought, bring back stdbool.h check back
Might be useful for uClibc (which still doesn't provide it) and others.
2015-12-29 19:44:50 +00:00
Mike Gelfand eb8fc35ac6 Remove useless checks and definitions (C99)
Now that MSVC support for C99 is quite good, remove previously needed but
now unused checks and definitions, like PRI* format macros (including
PRIdMAX and TR_PRIuSIZE, replaced with %jd and %zu) and inline macro.
Also, remove ssize_t typedef and replace few occurences with ev_ssize_t.
Also, remove check for stdbool.h availability (guaranteed by C99) and
include it unconditionally (except when in C++ mode).
2015-12-29 19:37:31 +00:00
Mike Gelfand eee92c82ac Always add all source files to targets
Mark files which shouldn't be compiled as header-only, but still add
them as sources so that they are visible in e.g. MSVS project tree.
2015-12-29 02:04:37 +00:00
Mike Gelfand db9d46bb91 Would you please die already, nasty chdir warning... 2015-12-29 00:48:55 +00:00
Mike Gelfand a6d4bd35fc Get rid of some more warnings 2015-12-29 00:42:40 +00:00
Mike Gelfand 15c9e5c126 Get rid of some more warnings 2015-12-28 23:53:55 +00:00
Mike Gelfand 4f266a5b15 Optimize URL-parsing functions a bit; rewrite `tr_urlParse()` 2015-12-28 23:52:26 +00:00
Mike Gelfand d0e157eceb Fix bitfield bit removal, add more asserts, extend unit test 2015-12-27 16:34:47 +00:00