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

Add integer overflow check #72

Merged
merged 1 commit into from
Apr 10, 2024
Merged

Add integer overflow check #72

merged 1 commit into from
Apr 10, 2024

Conversation

OuyangHang33
Copy link
Collaborator

Fix: #71

let (payload_length, bytes_consumed) = check_length(&data[index + 1..])?;
if index + 1 + bytes_consumed + payload_length > len {
Copy link
Member

Choose a reason for hiding this comment

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

to avoid overflow, the best way is to use minus. if bytes_consumed + payload_length > len - (index + 1)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it. I have changed it with minus.

Signed-off-by: OuyangHang33 <[email protected]>
@xiaoyuxlu
Copy link
Collaborator

Looks good to me. The fuzz test of nearly 20 hours was run. No issue found.

@jyao1 jyao1 merged commit cd6d5fe into ccc-spdm-tools:main Apr 10, 2024
52 checks passed
@OuyangHang33 OuyangHang33 deleted the i71 branch April 28, 2024 13:07
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.

Add integer overflow check in x509v3.rs while loop
3 participants