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

fix: invalid allocation requests #118

Merged
merged 1 commit into from
Feb 26, 2024
Merged

fix: invalid allocation requests #118

merged 1 commit into from
Feb 26, 2024

Conversation

ahmedcharles
Copy link
Contributor

Invalid data can lead to allocating too much memory. Only preallocate up to 1024 Value objects.

Fixes: #115

Invalid data can lead to allocating too much memory. Only preallocate up
to 1024 `Value` objects.

Fixes: enarx#115

Signed-off-by: Ahmed Charles <[email protected]>
@ahmedcharles ahmedcharles marked this pull request as ready for review February 26, 2024 12:59
@ahmedcharles ahmedcharles requested a review from a team as a code owner February 26, 2024 12:59
@ahmedcharles ahmedcharles requested a review from haraldh February 26, 2024 12:59
@rjzak
Copy link
Member

rjzak commented Feb 26, 2024

Fantastic! Just looks like clippy doesn't like an unused import.

@rjzak rjzak merged commit e305f1c into enarx:main Feb 26, 2024
52 of 53 checks passed
@ahmedcharles ahmedcharles deleted the fuzz branch February 26, 2024 23:52
@ahmedcharles
Copy link
Contributor Author

Sorry, I had an interim fix that used size_of but decided to go with something simpler.

@@ -124,7 +124,9 @@ impl<'de> serde::de::Visitor<'de> for Visitor {

#[inline]
fn visit_map<A: de::MapAccess<'de>>(self, mut acc: A) -> Result<Self::Value, A::Error> {
let mut map = Vec::<(Value, Value)>::with_capacity(acc.size_hint().unwrap_or(0));
let mut map = Vec::<(Value, Value)>::with_capacity(
acc.size_hint().filter(|&l| l < 1024).unwrap_or(0),

Choose a reason for hiding this comment

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

Description says:

Only preallocate up to 1024 Value objects.

But this code will not allocate at all when size hint >= 1024.

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.

[Bug]: sometimes fuzz fails in CI
3 participants