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

Fixes warnings for sign-compare #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kcalvinalvin
Copy link
Member

Fixes the code so that the sign comparison warnings go away.

@@ -56,7 +56,7 @@ bool BatchProof::Unserialize(const std::vector<uint8_t>& bytes)
return false;
}

int data_offset = 0;
uint8_t data_offset = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty sure this would overflow as an uint8_t while reading the hashes here:

data_offset += 32;

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to uint32_t.

Fixes the code so that the sign comparison warnings go away.
@@ -162,7 +162,7 @@ bool UndoBatch::Unserialize(const std::vector<uint8_t>& bytes)
return false;
}

int data_offset = 0;
uint8_t data_offset = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it will overflow here

data_offset += 4;
or
data_offset += 32;

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

Successfully merging this pull request may close these issues.

2 participants