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
returnnil, fmt.Errorf("core/fetcher: block not found, hash: %s", hash.String())
}
returnres.Block, nil
}
we notice that the first condition checks if res != nil and then if res.Block == nil. However by the time that we are checking if res != nil it can really be nil, yet on line 81 we are nakedly dereferncing res.Block
Suggestion
That code could be made much more whole and include a check for if res == nil || res.Block == nil { and then also add a test.
odeke-em
changed the title
core: BlockFetcher.GetBlockByHeight is susceptible to a panic due to insufficient nil checks
core: BlockFetcher.(GetBlock, GetBlockByHeight) are susceptible to a panic due to insufficient nil checks
Oct 5, 2024
If we examine this code
celestia-node/core/fetcher.go
Lines 76 to 81 in 896a46b
if res != nil and then if res.Block == nil
. However by the time that we are checkingif res != nil
it can really be nil, yet on line 81 we are nakedly dereferncing res.BlockSuggestion
That code could be made much more whole and include a check for
if res == nil || res.Block == nil {
and then also add a test./cc @Wondertan @liamsi @cristaloleg
The text was updated successfully, but these errors were encountered: