Fixed Integer overflow for TerraShatterer#5012
Open
DefaultEugene wants to merge 1 commit into
Open
Conversation
Collaborator
|
Did you actually find an overflow scenario? The only way mana is added to the Terra Shatterer is via a mana pool, and that should be limiting the amount of mana to exactly reach the maximum. [edit] (Though I agree the limitation implemented in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi there!
I found an issue with the TerraShatterer. Since its mana cap is
Integer.MAX_VALUE, it is the only item vulnerable to the Integer Overflow problemIf the pickaxe has
(MAX_MANA - 5)mana and we try to add 10 mana, the mana value will wrap around and reset to 0. I've fixed it using a safe comparison before addingI also want to draw attention to the
getManamethod: it returnsstack mana * stack count, which can also cause an overflow. However, that bug is not as critical as this one (since it requires astack size > 1for an unstackable item) and would require a much more complex fix using long arithmetics