You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The parameter MAX_SINGLE_PEER_RETRIES may not behave as expected due to an off-by-one error.
Description
Finding Off-by-One Errors and Inconsistent Usage of PARAMETER_DOWNLOAD_MAX_RETRIES documented an off-by-one issue with retry behavior in zebra-consensus. This finding documents a similar issue in zebra-network. Note that this does not represent a security issue or vulnerability, outside of potential user error during configuration.
The following code is part of peer DNS resolution, where each peer is resolved individually, and the complete process is repeated if no resolution is successful. The parameter MAX_SINGLE_PEER_RETRIES implies that it dictates the number of retry attempts for a given peer.
The retry function loops using for retry_count in 1..=max_retries, meaning that the value MAX_SINGLE_PEER_RETRIES will result in 1 single attempt and not 1 retry. Therefore, this parameter may be better named as MAX_SINGLE_PEER_ATTEMPTS or the behavior could be updated to loop one additional time.
Recommendation
Ensure the naming of the parameter accurately reflects its usage. Either rename the parameter to reflect the maximum number of connection attempts or revise the behavior to reflect its current name.
Impact
The parameter
MAX_SINGLE_PEER_RETRIES
may not behave as expected due to an off-by-one error.Description
Finding Off-by-One Errors and Inconsistent Usage of
PARAMETER_DOWNLOAD_MAX_RETRIES
documented an off-by-one issue with retry behavior inzebra-consensus
. This finding documents a similar issue inzebra-network
. Note that this does not represent a security issue or vulnerability, outside of potential user error during configuration.The following code is part of peer DNS resolution, where each peer is resolved individually, and the complete process is repeated if no resolution is successful. The parameter
MAX_SINGLE_PEER_RETRIES
implies that it dictates the number of retry attempts for a given peer.zebra/zebra-network/src/config.rs
Lines 25 to 27 in 5a88fe7
zebra/zebra-network/src/config.rs
Lines 161 to 170 in 5a88fe7
The
retry
function loops usingfor retry_count in 1..=max_retries
, meaning that the valueMAX_SINGLE_PEER_RETRIES
will result in 1 single attempt and not 1 retry. Therefore, this parameter may be better named asMAX_SINGLE_PEER_ATTEMPTS
or the behavior could be updated to loop one additional time.Recommendation
Ensure the naming of the parameter accurately reflects its usage. Either rename the parameter to reflect the maximum number of connection attempts or revise the behavior to reflect its current name.
Location
zebra-network/src/config.rs
The text was updated successfully, but these errors were encountered: