HomePhabricator

Add bounds checking to seeder arguments with integer base types

Description

Add bounds checking to seeder arguments with integer base types

Summary:
The seeder does not implement bounds checking for integer typed arguments.
In most cases, no error or warning is presented to the user that indicates the seeder
is not operating correctly.
In some cases, strange behavior is produced (for example, negative port values underflow).

Test Plan:

ninja bitcoin-seeder check-seeder

Listening port is still correct (verify with sudo netstat -pln | grep seeder):

./src/seeder/bitcoin-seeder -host=seeder.status.cash -ns=localhost -mbox=thonkle@protonmail.com -port=53
./src/seeder/bitcoin-seeder -host=seeder.status.cash -ns=localhost -mbox=thonkle@protonmail.com -port=5555

Use ls /proc/$(pgrep seeder)/task/ | wc -l to verify number of threads:

./src/seeder/bitcoin-seeder -host=seeder.status.cash -ns=localhost -mbox=thonkle@protonmail.com -port=5555  # expect 104
./src/seeder/bitcoin-seeder -host=seeder.status.cash -ns=localhost -mbox=thonkle@protonmail.com -port=5555 -threads=1  # expect 9
./src/seeder/bitcoin-seeder -host=seeder.status.cash -ns=localhost -mbox=thonkle@protonmail.com -port=5555 -dnsthreads=1  # expect 101
./src/seeder/bitcoin-seeder -host=seeder.status.cash -ns=localhost -mbox=thonkle@protonmail.com -port=5555 -threads=2 -dnsthreads=2  # expect 8

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10748

Details

Provenance
thonkleAuthored on Dec 31 2021, 23:07
thonklePushed on Jan 31 2022, 15:17
Reviewer
Restricted Owners Package
Differential Revision
D10748: Add bounds checking to seeder arguments with integer base types
Parents
rABCd3a5c3e4328d: [p2p] Reduce addr blackholes
Branches
Unknown
Tags
Unknown