Commit graph

24369 commits

Author SHA1 Message Date
MarcoFalke 4fa3157014
Merge #18929: ci: Pass down LD_LIBRARY_PATH and MAKEJOBS to fuzz test_runner
cbd661122e Set LD_LIBRARY_PATH consistently in travis tests (Russell Yanofsky)
fa35c34df7 Remove unused ci configs that have been moved elsewhere (MarcoFalke)
3333cb9699 fuzz: Pass down MAKEJOBS to test_runner (MarcoFalke)

Pull request description:

  Just how `MAKEJOBS` is passed down to the functional test `test_runner`, do the same for the fuzz `test_runner`.

  Also includes a commit to remove unused config files, which have been moved elsewhere.

Top commit has no ACKs.

Tree-SHA512: 32557102c9e40599b432aeb004c8427e8fbb07cdf4048050cdc8241d1b029aaad306b1131007eeca8315a4f71c38a7efbb833310e056cd11b835676cd19b8902
2020-05-12 07:37:31 -04:00
fanquake e3047edfb6
test: use p2p constants in denial of service tests 2020-05-12 17:30:33 +08:00
tryphe 25d8264c95
p2p: add MAX_FEELER_CONNECTIONS constant 2020-05-12 17:30:33 +08:00
fanquake 0f2fa599ae
Merge #18931: net: use CMessageHeader::HEADER_SIZE, add missing include
83da576f44 net: use CMessageHeader::HEADER_SIZE, add missing include (Jon Atack)

Pull request description:

  as suggested 16 months ago by Gleb Naumenko in https://github.com/bitcoin/bitcoin/pull/15197#issuecomment-456181865.

  `static constexpr CMessageHeader::HEADER_SIZE` is already used in this file, `src/net.cpp`, in 2 instances. This commit replaces the remaining 2 integer values in the file with it and adds the explicit include header.

  Co-authored by: Gleb Naumenko <naumenko.gs@gmail.com>

ACKs for top commit:
  naumenkogs:
    utACK 83da576
  practicalswift:
    ACK 83da576f44 -- patch looks correct
  theStack:
    ACK 83da576f44 -- verified that its just magic number elimination refactoring and additionally checked that all tests pass 👍

Tree-SHA512: 5b915483bca4ea162c259865a1b615d73b88a1b1db3f82db05f770d10b8a42494d948f5b21badbcce2d9efa5915b8cbb6af83073867c23d2f152c0d35ac37b96
2020-05-12 17:05:40 +08:00
fanquake ad1b7b1817
Merge #18957: Add a link from ZMQ doc to ZMQ example in contrib/
d97fac422e Add a link from ZMQ doc to ZMQ example in contrib/ (Damian Mee)

Pull request description:

  No code changes :).  Only a small convenience improvement in zmq doc.

ACKs for top commit:
  fanquake:
    ACK d97fac422e

Tree-SHA512: f05a8a7a77c0a698637fd24ffc94d0d617743b434f46695a56576a53331ede254aeece416baf3f8275ae4dfad85ae6e14d1920aa32af53150847420a176d90fb
2020-05-12 16:42:12 +08:00
fanquake 49d237ce32
Merge #18928: build: don't pass -w when building for Windows
89fea68ffd build: don't pass -w when building for Windows (fanquake)

Pull request description:

  This has been around since the introduction of autotools. However at
  this point I'm not sure we'd ever want to suppress all warnings when
  performing a build, and given that CXX FLAGS will have been overriden
  when cross-compiling for Windows (using depends), this would rarely,
  if-ever be used anyways.

  From https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html:
  > -w
  >
  >     Inhibit all warning messages.

ACKs for top commit:
  hebasto:
    ACK 89fea68ffd

Tree-SHA512: 2b5bdef7fff5c87b28199f5822cab3cdf600c90c01a40db5cd85053eef5dcb5816e2e97ff61a30ff94b4f0c6cb7be22beaef34d82235bdf05ff9da865d40b381
2020-05-12 16:17:15 +08:00
Damian Mee d97fac422e
Add a link from ZMQ doc to ZMQ example in contrib/ 2020-05-12 16:06:28 +08:00
fanquake 7a5767423f
Merge #18808: [net processing] Drop unknown types in getdata
9847e205bf [docs] Improve commenting in ProcessGetData() (John Newbery)
2f032556e0 [test] test that an invalid GETDATA doesn't prevent processing of future messages (Amiti Uttarwar)
e257cf71c8 [net processing] ignore unknown INV types in GETDATA messages (Amiti Uttarwar)
047ceac142 [net processing] ignore tx GETDATA from blocks-only peers (Amiti Uttarwar)

Pull request description:

  Currently we'll stall peers that send us an unknown INV type in a GETDATA message. Be a bit more friendly and just drop the invalid request.

  Ditto for blocks-relay-only peers that send us a GETDATA for a transaction.

  There's a test for the first part. The second is difficult to test in the functional test framework since we aren't able to make blocks-relay-only connections.

ACKs for top commit:
  sipa:
    utACK 9847e205bf
  brakmic:
    ACK 9847e205bf
  luke-jr:
    utACK 9847e205bf
  naumenkogs:
    utACK 9847e20
  ajtowns:
    utACK 9847e205bf

Tree-SHA512: 6007f2fd839ffe737727f6fb8e8f083b2d9e05a510748f1d40b8f9be8fdf7b5419a36d8f1039923eec1ba2983e8f6f0436ec5fc196d9f6dcb0657f2ff8ff8e4c
2020-05-12 09:13:48 +08:00
Ferdinando M. Ametrano 8a22fd0114
avoided os-dependant path
The current code fails on windows because of the forward slashes; using os.path.join solves the problem and it is in general more robust
2020-05-11 22:31:02 +02:00
Hennadii Stepanov de5e91c303
refactor: Add BerkeleyDatabaseVersion() function 2020-05-11 20:42:55 +03:00
MarcoFalke eb2ffbb7c1
Merge #18914: refactor: Apply override specifier consistently
d044e0ec7d refactor: Remove override for final overriders (Hennadii Stepanov)
1551cea2d5 refactor: Use override for non-final overriders (Hennadii Stepanov)

Pull request description:

  Two commits are split out from #16710 to make reviewing [easier](https://github.com/bitcoin/bitcoin/pull/16710#issuecomment-625760894).

  From [C++ FAQ](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines.html#c128-virtual-functions-should-specify-exactly-one-of-virtual-override-or-final):
  > C.128: Virtual functions should specify exactly one of virtual, override, or final
  > **Reason** Readability. Detection of mistakes. Writing explicit `virtual`, `override`, or `final` is self-documenting and enables the compiler to catch mismatch of types and/or names between base and derived classes. However, writing more than one of these three is both redundant and a potential source of errors.

ACKs for top commit:
  practicalswift:
    ACK d044e0ec7d: consistent use of `override` prevents bugs + patch looks correct + Travis happy
  MarcoFalke:
    ACK d044e0ec7d, based on my understanding that adding `override` or `final` to a function must always be correct, unless it doesn't compile!?
  vasild:
    ACK d044e0ec7

Tree-SHA512: 245fd9b99b8b5cbf8694061f892cb3435f3378c97ebed9f9401ce86d21890211f2234bcc39c9f0f79a4d2806cb31bf8ce41a0f9c2acef4f3a2ac5beca6b077cf
2020-05-11 13:34:07 -04:00
MarcoFalke f71a3a8829
Merge #18939: doc: add c++17-enable flag to fuzzing instructions
872aa25fa1 doc: add c++17-enable to fuzzing instructions (Martin Zumsande)

Pull request description:

  Update the fuzzing doc because after the merge of #18901, C++17 is required for compilation.

ACKs for top commit:
  practicalswift:
    ACK 872aa25fa1
  MarcoFalke:
    ACK 872aa25fa1

Tree-SHA512: 47e37c033690de1d1fa644bf0cebb256036b32a5784021cc0d3b32e6188822d7f517d4342990dc7ec98de6d650794aeb85483157e69e141d6bd011993e124575
2020-05-11 10:08:04 -04:00
MarcoFalke fa1f840596
rpcwallet: Replace pwallet-> with wallet.
pwallet is never null everywhere where it is dereferenced, so simply
replace it with a reference, which can not be null by definition.
2020-05-11 09:59:00 -04:00
MarcoFalke fa182a8794
rpcwallet: Replace boost::optional<T>::emplace with simple assignment of T{}
Optional::emplace() was only added in boost 1.56, see
2e583aaf30

To simply work around https://github.com/bitcoin/bitcoin/issues/18943,
replace it with assignment of T{}
2020-05-11 09:53:49 -04:00
fanquake ec4d27fa8b
Merge #18216: test, build: Enable -Werror=sign-compare
68537275bd build: Enable -Werror=sign-compare (Ben Woosley)
eac6a3080d refactor: Rework asmap Interpret to avoid ptrdiff_t (Ben Woosley)
df37377e30 test: Fix outstanding -Wsign-compare errors (Ben Woosley)

Pull request description:

  Disallowing sign-comparison mismatches can help to prevent the introduction of overflow and interpretation bugs.

  In this case, ~all~ most existing violations are in the tests, and most simply required annotating the literal as unsigned for comparison.

  This was previously prevented by violations in leveldb which were fixed upstream and merged in #17398. You can test that by building this branch against: 22d11187ee vs 75fb37ce68

ACKs for top commit:
  fjahr:
    re-ACK 68537275bd
  practicalswift:
    ACK 68537275bd

Tree-SHA512: 14b5daa38c496fb51548feb30fb4dd179e6f76a8d355f52bc8e2a18f2f9340f0bc98dcf36d8b3d6521045d013891c3103749a4eda88ceef00202a6a0cf93f73c
2020-05-11 12:20:25 +08:00
Martin Zumsande 872aa25fa1 doc: add c++17-enable to fuzzing instructions 2020-05-11 01:18:17 +02:00
Hennadii Stepanov 78be8d97d3
util: Drop OpOriginal() and OpTranslated()
The current implementation of the Join() allows do not use OpOriginal()
and OpTranslated() unary operators at all.
2020-05-10 21:28:29 +03:00
Hennadii Stepanov da16f95c3f
gui: Do not translate InitWarning messages in debug.log 2020-05-10 18:01:28 +03:00
Hennadii Stepanov 4c9b9a4882
util: Enhance Join() 2020-05-10 18:00:19 +03:00
Russell Yanofsky cbd661122e Set LD_LIBRARY_PATH consistently in travis tests
Remove inconsistency between functional and unit test environments and make it
possible to substitute bitcoin-qt and bitcoin-node in place of bitcoind in
python tests, or to link bitcoind against shared libraries.
2020-05-10 10:35:17 -04:00
Jon Atack 83da576f44
net: use CMessageHeader::HEADER_SIZE, add missing include
static constexpr CMessageHeader::HEADER_SIZE is already used in this file,
src/net.cpp, in 2 instances. This commit replaces the remaining 2 integer
values with it and adds the explicit include header.

Co-authored by: Gleb Naumenko <naumenko.gs@gmail.com>
2020-05-10 15:58:42 +02:00
MarcoFalke fa35c34df7
Remove unused ci configs that have been moved elsewhere
They have been moved to https://github.com/MarcoFalke/btc_nightly
running on Cirrus CI https://cirrus-ci.com/build/6249975761862656
2020-05-10 07:51:31 -04:00
MarcoFalke 3333cb9699
fuzz: Pass down MAKEJOBS to test_runner 2020-05-10 07:49:09 -04:00
fanquake 89fea68ffd
build: don't pass -w when building for Windows
This has been around since the introduction of autotools. However at
this point I'm not sure we'd every want to suppress all warnings when
performing a build, and given that CXX FLAGS will have been overriden
when cross-compiling for Windows (using depends), this would rarely,
if-ever be used anyways.

From https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html:
-w

    Inhibit all warning messages.
2020-05-10 19:27:15 +08:00
Hennadii Stepanov fe05dd0611
util: Enhance bilingual_str 2020-05-09 16:43:51 +03:00
MarcoFalke 88d8b4e182
Merge #18901: fuzz: use std::optional for sep_pos_opt variable
420fa0770f fuzz: use std::optional for sep_pos variable (Harris)

Pull request description:

  This PR changes the original `size_t sep_pos` to `std::optional<size_t> sep_post_opt` to remove the warning when compiling fuzz tests.

  ```shell
  warning: variable 'sep_pos' may be uninitialized when used here [-Wconditional-uninitialized]
  ```

  Also, it adds `--enable-c++17` flag to CI fuzz scripts.

ACKs for top commit:
  practicalswift:
    ACK 420fa0770f
  MarcoFalke:
    ACK 420fa07

Tree-SHA512: e967d5d8ab8ee7394b243ff5b28bac72d30bd14774e4a206f8c87474fad22769da76e4ba4e03cbef83b8f60e5293e9d9293b613e2e2e59e187d4e59ae6b874ca
2020-05-09 07:30:37 -04:00
Harris 420fa0770f
fuzz: use std::optional for sep_pos variable
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2020-05-09 11:09:52 +02:00
Ben Woosley 68537275bd
build: Enable -Werror=sign-compare
Explicitly add -Wsign-compare as well - not required for all compilers, as GCC activates it
under -Wall, but may impact clang, etc.
2020-05-09 00:20:09 -07:00
Ben Woosley eac6a3080d
refactor: Rework asmap Interpret to avoid ptrdiff_t 2020-05-09 00:20:00 -07:00
MarcoFalke 376294cde6
Merge #18866: test: Fix verack race to avoid intermittent test failures
fae153b409 test: Fix verack race to avoid intermittent test failures (MarcoFalke)

Pull request description:

  Fixes #18832

ACKs for top commit:
  laanwj:
    ACK fae153b409

Tree-SHA512: 071de8c8e2b2787c9433c7460e18b9a54beaf471a52ce848c5ac7263fc2a40f5b976d4f558ecc494fd0fa07284b7c98d29267cade58f80ab74fe9a7d18d94298
2020-05-08 19:31:17 -04:00
MarcoFalke b55866969e
Merge #18917: fuzz: fix vector size problem in system fuzzer
095bc9a106 fuzz: fix vector size problem in system fuzzer (Harris)

Pull request description:

  This PR fixes a problem with vector resizing in system fuzzer (*case 7* there). Originally, this problem was discussed in PR https://github.com/bitcoin/bitcoin/pull/18908

ACKs for top commit:
  MarcoFalke:
    ACK 095bc9a106
  practicalswift:
    ACK 095bc9a106
  brakmic:
    > ACK [095bc9a](095bc9a106)

Tree-SHA512: 73e6004ee51d68a34b49c79d1329a8c4865c21da888801c0fcc7f1bcacb510bf371bb61675eda83e53d08e0f24712e671369719523b0ced0eb2a22607bfa1d3d
2020-05-08 18:11:43 -04:00
Jim Posen 23083856a5 [test] Add test for cfcheckpt 2020-05-08 16:36:19 -04:00
Jim Posen f9e00bb25a [net processing] Message handling for getcfcheckpt.
If -peerblockfilters is configured, handle requests for cfcheckpt.
2020-05-08 16:36:19 -04:00
Jim Posen 9ccaaba11e [init] Add -peerblockfilters option
When a node is configured with --blockfilterindex=basic and
-peerblockfilters it can serve compact block filters to its peers.

This commit adds the configuration option handling. Future commits
add compact block serving and service bits signaling.
2020-05-08 16:36:18 -04:00
Harris 095bc9a106
fuzz: fix vector size problem in system fuzzer
Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
2020-05-08 20:21:48 +02:00
Ben Woosley df37377e30
test: Fix outstanding -Wsign-compare errors 2020-05-08 11:18:43 -07:00
MarcoFalke 5b24f6084e
Merge #16224: gui: Bilingual GUI error messages
18bd83b1fe util: Cleanup translation.h (Hennadii Stepanov)
e95e658b8e doc: Do not translate technical or extremely rare errors (Hennadii Stepanov)
7e923d47ba Make InitError bilingual (Hennadii Stepanov)
917ca93553 Make ThreadSafe{MessageBox|Question} bilingual (Hennadii Stepanov)
23b9fa2e5e gui: Add detailed text to BitcoinGUI::message (Hennadii Stepanov)

Pull request description:

  This is an alternative to #15340 (it works with the `Chain` interface; see: https://github.com/bitcoin/bitcoin/pull/15340#issuecomment-502674004).
  Refs:
  - #16218 (partial fix)
  - https://github.com/bitcoin/bitcoin/pull/15894#issuecomment-487947077

  This PR:
  - makes GUI error messages bilingual: user's native language + untranslated (i.e. English)
  - insures that only untranslated messages are written to the debug log file and to `stderr` (that is not the case on master).

  If a translated string is unavailable only an English string appears to a user.

  Here are some **examples** (updated):

  ![Screenshot from 2020-04-24 17-08-37](https://user-images.githubusercontent.com/32963518/80222043-e2458780-864e-11ea-83fc-197b7121dba5.png)

  ![Screenshot from 2020-04-24 17-12-17](https://user-images.githubusercontent.com/32963518/80222051-e5407800-864e-11ea-92f7-dfef1144becd.png)

  * `qt5ct: using qt5ct plugin` message is my local environment specific; please ignore it.

  ---

  Note for reviewers: `InitWarning()` is out of this PR scope.

ACKs for top commit:
  Sjors:
    re-tACK 18bd83b1fe
  MarcoFalke:
    ACK 18bd83b1fe 🐦

Tree-SHA512: 3cc8ec44f84403e54b57d11714c86b0855ed90eb794b5472e432005073354b9e3f7b4e8e7bf347a4c21be47299dbc7170f2d0c4b80e308205ff09596e55a4f96
2020-05-08 12:17:55 -04:00
MarcoFalke 3930014abc
Merge #18864: Add v0.16.3 backwards compatibility test, bump v0.19.0.1 to v0.19.1
d135c29476 [ci] make list of previous releases to download a setting (Sjors Provoost)
9c246b873c [test] backwards compatibility: bump v0.19.0.1 to v0.19.1 (Sjors Provoost)
89a28e02fa [test] add v0.16.3 backwards compatibility test (Sjors Provoost)

Pull request description:

  Thanks to #18774's `adjust_bitcoin_conf_for_pre_17` we can now test backwards compatibility for v0.16.3, both for sync and loading a recent wallet.

  This PR bumps v0.19.0.1 to v0.19.1.

  I also made the version list consistent for the `contrib/devtools/previous_release.sh` instruction, between both tests.

ACKs for top commit:
  MarcoFalke:
    ACK d135c29476

Tree-SHA512: 5ff137a7a934237fa220f1c2807ce9abeeb75929266558bf3e4045bec7dfcd0a8747fa74d700065c568330b18badf58c60c308eb13d1eed444d4bbfe6decc48b
2020-05-08 11:23:40 -04:00
Sjors Provoost d135c29476
[ci] make list of previous releases to download a setting
Co-Authored-By: MarcoFalke <falke.marco@gmail.com>
2020-05-08 16:13:29 +02:00
Hennadii Stepanov d044e0ec7d
refactor: Remove override for final overriders 2020-05-08 10:37:05 +03:00
Hennadii Stepanov 1551cea2d5
refactor: Use override for non-final overriders 2020-05-08 10:36:58 +03:00
MarcoFalke f54753293f
Merge #18905: travis: Remove s390x
8c705ff129 travis: Remove s390x (MarcoFalke)

Pull request description:

  Fixes #18868
  Fixes #18016

Top commit has no ACKs.

Tree-SHA512: 1007b761c7e01dd2b75aa34e92e01a92a84a100c0a3a53863c755d93b2438a74601e3f2083919b8a9cfc92fb104d0c8415fad3f6c9504c76b02ad2e9712660c0
2020-05-07 10:26:59 -04:00
MarcoFalke 8c705ff129 travis: Remove s390x 2020-05-07 09:58:57 -04:00
fanquake 56611b0e24
Merge #18743: depends: Add --sysroot option to mac os native compile flags
1e94a2bcbc depends: Add --sysroot option to mac os native compile flags (Russell Yanofsky)

Pull request description:

  Catalina SDK clang stopped automatically searching the SDK include paths when invoked without `--sysroot`:

  - https://github.com/bitcoin/bitcoin/pull/16367#issuecomment-594600985
  - https://github.com/Homebrew/homebrew-core/issues/45061

  This hasn't been a problem for current native depends packages because are passing their own `--sysroot` values, and hasn't been a problem for current host packages because they use `darwin_` commands instead of `build_darwin_` commands.  But the current `build_darwin_CC` and `build_darwin_CXX` commands are still unnecessarily fragile, and incompatible with new native depends packages added in https://github.com/bitcoin/bitcoin/pull/18677.

  Cory Fields (theuni) suggested in https://github.com/bitcoin/bitcoin/pull/16367#issuecomment-595393546 switching compiler from SDK clang to native clang (from $PATH) to avoid this problem. This is easy and makes a certain amount of sense for building native packages, as opposed to host packages. But Michael (fanquake) pointed out in https://github.com/bitcoin/bitcoin/pull/18677#discussion_r409934309 that it would be inconsistent to switch to non-SDK compilers while still using other SDK tools like `ranlib` and `install_name_tool`. So simplest, minimal fix seems to be just adding the missing `--sysroot` option.

ACKs for top commit:
  ryanofsky:
    > ACK [1e94a2b](1e94a2bcbc) - I think this change is ok, and I prefer it to the previous patch.
  fanquake:
    ACK 1e94a2bcbc - I think this change is ok, and I prefer it to the previous patch. Thanks for the summary in the PR description. I played around with Xcode and the CLT; I think previously I didn't fully grok the slight differences between the two.

Tree-SHA512: 4d4bbb7f49acb76d934a872a15b4e14f36290b508cb9e728815f959767ec174bcfb6d2ca7dcd995cc550d86980d64d4247ea5ecfca2301f0953006e50744fdb4
2020-05-07 20:59:57 +08:00
Sebastian Falbesoner 4a614ff88a test: explicit imports from test_framework.messages in p2p_invalid_messages.py 2020-05-07 14:34:55 +02:00
Sebastian Falbesoner b35e1d2471 test: add inventory type constant MSG_CMPCT_BLOCK 2020-05-07 14:34:55 +02:00
Sebastian Falbesoner eeaaa58d2c test: replace inv type magic numbers by constants 2020-05-07 14:34:55 +02:00
MarcoFalke c1cd2b5a97
Merge #18899: travis: Remove valgrind
fa082d0a57 travis: Remove valgrind (MarcoFalke)

Pull request description:

  When the valgrind run was added, it took 2 hours. Travis kindly raised the timeout limit to the maximum possible of 3 hours.

  Today, a full build of Bitcoin Core with all tests takes more than three hours. Thus, it is impossible to run all tests on travis.

  Moreover, the feedback loop for developers that create a pull request takes at least 2 hours, but in some cases (when the travis queue is full) until the next day. This is unacceptable.

  Fix both issues by removing the build from travis.

  Please note that the `ci/test/` configurations are *not* removed. They will stay in the repo and can be executed anywhere (just not on travis).

ACKs for top commit:
  jamesob:
    ACK fa082d0a57
  jnewbery:
    utACK fa082d0a57

Tree-SHA512: 9acaa0e2d3926014fadb7dd2e86c4e01df382e9399f6ae99f989fa609da66a77bdd1b75d6ff42d2686f38f730b8564e6dc722aa597a473290c9d30c2abe7ef0f
2020-05-07 07:56:33 -04:00
fanquake df6bde031b
test: remove glibc fdelt sanity check
As is, this sanity check doesn't seem to be testing fdelt_chk, because
passing a value of "0" to FD_SET wont cause the compiler to insert any
calls to fdelt_chk().

The documentation is a little misleading. If we actually triggered fdelt_chk
at runtime, bitcoind would abort. I think this check would be better replaced
(if possible) by additional checks in security-check.py.

The compiler may insert a call to fdelt_warn() (aliased with fdelt_chk
in glibc) at compile time if it can determine that an invalid value is
being passed to FD_SET.

These checks are essentially; value < 0 or value >= FD_SETSIZE along
with a check for wether the value is a compile time constant.

If the compiler can determine an invalid value is being passed, a call
to fdelt_warn will be inserted. Passing 0 should never cause a call to
be inserted.

You can check this after compiling:
```bash
objdump -dC bitcoind | grep sanity_fdelt
...
0000000000399d20 <sanity_test_fdelt()>:
  399d20:	48 81 ec 98 00 00 00 	sub    $0x98,%rsp
  399d27:	b9 10 00 00 00       	mov    $0x10,%ecx
  399d2c:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
  399d33:	00 00
  399d35:	48 89 84 24 88 00 00 	mov    %rax,0x88(%rsp)
  399d3c:	00
  399d3d:	31 c0                	xor    %eax,%eax
  399d3f:	48 89 e7             	mov    %rsp,%rdi
  399d42:	fc                   	cld
  399d43:	f3 48 ab             	rep stos %rax,%es:(%rdi)
  399d46:	48 8b 84 24 88 00 00 	mov    0x88(%rsp),%rax
  399d4d:	00
  399d4e:	64 48 33 04 25 28 00 	xor    %fs:0x28,%rax
  399d55:	00 00
  399d57:	75 0d                	jne    399d66 <sanity_test_fdelt()+0x46>
  399d59:	b8 01 00 00 00       	mov    $0x1,%eax
  399d5e:	48 81 c4 98 00 00 00 	add    $0x98,%rsp
  399d65:	c3                   	retq
  399d66:	e8 85 df c8 ff       	callq  27cf0 <__stack_chk_fail@plt>
  399d6b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)

```

To test, you could modify this test to pass -1 to FD_SET, and check
that a call to fdelt_warn() is inserted, and that running bitcoind
fails. i.e:

```bash
0000000000399d20 <sanity_test_fdelt()>:
  399d20:	48 81 ec 98 00 00 00 	sub    $0x98,%rsp
  399d27:	b9 10 00 00 00       	mov    $0x10,%ecx
  399d2c:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
  399d33:	00 00
  399d35:	48 89 84 24 88 00 00 	mov    %rax,0x88(%rsp)
  399d3c:	00
  399d3d:	31 c0                	xor    %eax,%eax
  399d3f:	48 89 e7             	mov    %rsp,%rdi
  399d42:	fc                   	cld
  399d43:	f3 48 ab             	rep stos %rax,%es:(%rdi)
  399d46:	48 c7 c7 ff ff ff ff 	mov    $0xffffffffffffffff,%rdi
  399d4d:	e8 3e ff ff ff       	callq  399c90 <__fdelt_warn>
  399d52:	0f b6 04 24          	movzbl (%rsp),%eax
  399d56:	83 e0 01             	and    $0x1,%eax
  399d59:	48 8b 94 24 88 00 00 	mov    0x88(%rsp),%rdx
  399d60:	00
  399d61:	64 48 33 14 25 28 00 	xor    %fs:0x28,%rdx
  399d68:	00 00
  399d6a:	75 08                	jne    399d74 <sanity_test_fdelt()+0x54>
  399d6c:	48 81 c4 98 00 00 00 	add    $0x98,%rsp
  399d73:	c3                   	retq
  399d74:	e8 77 df c8 ff       	callq  27cf0 <__stack_chk_fail@plt>
  399d79:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)

```

```bash
./src/bitcoind
*** buffer overflow detected ***: src/bitcoind terminated
Aborted
```
2020-05-07 15:45:09 +08:00
fanquake 8bf1540cc2
build: remove fdelt_chk backwards compatibility code
Now that we require glibc 2.17 or later, we no longer need to check for
different return types in fdelt_chk. It was changed from unsigned long
int to long int in glibc 2.16 . See this commit:
https://sourceware.org/git/?p=glibc.git;a=commit;h=ceb9e56b3d1f8c1922e0526c2e841373843460e2
and related issue:
https://sourceware.org/bugzilla/show_bug.cgi?id=14210.
2020-05-07 15:44:56 +08:00