HomePhabricator

[avalanche] add additional safety checks before dereferencing g_avalanche in…

Description

[avalanche] add additional safety checks before dereferencing g_avalanche in net_processing

Summary:
Make sure every access to g_avalanche is preceded in the same scope by an early return if the pointer is null.

In ProcessMessage, we return early at the beginning of the function if IsAvalancheMessageType(msg_type) && !g_avalanche, but this is a weak guarantee as the IsAvalancheMessageType function could be buggy or not up to date.

In ProcessGetData, if the request is for a proof, we didn't actually guard against g_avalanche being a nullptr. Luckily when running bitcoind and when the node starts processing inbound messages, the processor is always already initialized. Add a continue in that loop to skip the processing if g_avalanche is nullptr anyway.

Depends on D16250

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
PiRKAuthored on May 30 2024, 12:11
PiRKPushed on May 31 2024, 06:15
Reviewer
Restricted Project
Differential Revision
D16255: [avalanche] add additional safety checks before dereferencing g_avalanche in net_processing
Parents
rABCebfc56b49c6b: [Cashtab] Implement ecash-lib for tx building
Branches
Unknown
Tags
Unknown