Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p2p: ExchangeServer.handleRangeRequest should assert that from < to #224

Open
odeke-em opened this issue Oct 22, 2024 · 1 comment
Open

Comments

@odeke-em
Copy link

go-header/p2p/server.go

Lines 200 to 203 in 18f0eb1

func (serv *ExchangeServer[H]) handleRangeRequest(ctx context.Context, from, to uint64) ([]H, error) {
if from == uint64(0) {
return serv.handleHeadRequest(ctx)
}

Should also include a check that from < to. Having worked on a bunch of networking, the pain of debugging simple coding errors like a mix up between ranges can be hell and not worth the time, hence insure future selves by simply returning an error when from >= to

Kindly cc-ing @Wondertan

@walldiss
Copy link
Member

Hey, thanks for pointing that out!

I totally agree - adding a check to ensure from < to will help prevent any range mix-ups and make the code more robust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants