Skip to content

jsonbuilder: attempt to handle memory allocation errors - v3#8901

Closed
jasonish wants to merge 4 commits into
OISF:masterfrom
jasonish:jsonbuilder-alloc/v3
Closed

jsonbuilder: attempt to handle memory allocation errors - v3#8901
jasonish wants to merge 4 commits into
OISF:masterfrom
jasonish:jsonbuilder-alloc/v3

Conversation

@jasonish
Copy link
Copy Markdown
Member

Previous PR: #8855
Ticket: https://redmine.openinfosecfoundation.org/issues/6057

Changes from previous PR:

  • Catch a missing push
  • Check allocation for state
  • Fix base64 length calculation

Not addressed:

  • Estimating and reserving in one chunk. Given that each push will reserve more than it should need, not sure if this is a much of a win anyways.

jasonish added 4 commits May 18, 2023 22:18
Some very minor changes to formatting.
Convert "new_object" and "new_array" functions that return a Result
and use "try_reserve" to allocate the amount of data requested. This
should allow memory allocation errors to be detected and handled in a
Rust-ful matter without resorting to catching a panic.

Ticket: OISF#6057
Before growing any buffers use try_reserve to reserve the space required
as this will return an error on allocation failures.

Ticket: OISF#6057
Required minor updates to users of the base64 crate.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2023

Codecov Report

Merging #8901 (c7e8820) into master (3247e39) will decrease coverage by 0.01%.
The diff coverage is 86.75%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8901      +/-   ##
==========================================
- Coverage   82.30%   82.30%   -0.01%     
==========================================
  Files         969      969              
  Lines      273335   273378      +43     
==========================================
+ Hits       224960   224992      +32     
- Misses      48375    48386      +11     
Flag Coverage Δ
fuzzcorpus 64.67% <77.71%> (+0.07%) ⬆️
suricata-verify 60.44% <80.57%> (+0.02%) ⬆️
unittests 62.95% <65.75%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link
Copy Markdown

Information: QA ran without warnings.

Pipeline 13846

@catenacyber
Copy link
Copy Markdown
Contributor

commit-check failed ?

@jasonish
Copy link
Copy Markdown
Member Author

commit-check failed ?

Yeah, got sloppy rebasing. Will fixup today or tomorrow.

@jasonish
Copy link
Copy Markdown
Member Author

Fixed: #8916

@jasonish jasonish closed this May 24, 2023
@jasonish jasonish deleted the jsonbuilder-alloc/v3 branch May 31, 2023 21:29
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.

3 participants