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

Limit manifest's change set size #1119

Merged
merged 2 commits into from
Nov 20, 2019
Merged

Conversation

jarifibrahim
Copy link
Contributor

@jarifibrahim jarifibrahim commented Nov 13, 2019

This PR limits the amount of memory we allocated for reading the manifest changes set's size.
When a manifest file is corrupted, in worst case we might end up allocating more than 4GB in the following make call

badger/manifest.go

Lines 368 to 369 in eef7c12

length := y.BytesToU32(lenCrcBuf[0:4])
var buf = make([]byte, length)

This PR ensures we don't over-allocate the byte slice.
Fixes #490


This change is Reviewable

@coveralls
Copy link

coveralls commented Nov 14, 2019

Coverage Status

Coverage increased (+0.003%) to 77.387% when pulling a36669f on ibrahim/limit-manifest into eef7c12 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 77.357% when pulling a36669f on ibrahim/limit-manifest into eef7c12 on master.

Copy link
Contributor

@ashish-goswami ashish-goswami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can check it same thing can be at other places also. :lgtm:

Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @ashish-goswami and @manishrjain)

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@jarifibrahim jarifibrahim merged commit 5f94f68 into master Nov 20, 2019
@jarifibrahim jarifibrahim deleted the ibrahim/limit-manifest branch November 20, 2019 18:38
jarifibrahim pushed a commit that referenced this pull request Mar 12, 2020
This PR limits the amount of memory we allocated for reading
the manifest changes set's size. When a manifest file is corrupted,
in the worst case we might end up allocating more than 4GB.

This PR ensures we don't over-allocate the byte slice.
Fixes #490

(cherry picked from commit 5f94f68)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Limit manifest's change set size
4 participants