Skip to content

fix(bits): prevent BitArray.UnmarshalJSON from crashing on 0 bits in the JSON (backport #2774)#2777

Merged
melekes merged 1 commit intov1.xfrom
mergify/bp/v1.x/pr-2774
Apr 11, 2024
Merged

fix(bits): prevent BitArray.UnmarshalJSON from crashing on 0 bits in the JSON (backport #2774)#2777
melekes merged 1 commit intov1.xfrom
mergify/bp/v1.x/pr-2774

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Apr 11, 2024

This change fixes a bug in which BitArray.UnmarshalJSON hadn't accounted for the fact that invoking NewBitArray(<=0) returns nil and hence when dereferenced would crash with a runtime nil pointer dereference. This bug was found by my security analysis and fuzzing too.

Author: @odeke-em

Fixes #2658


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments
  • Title follows the Conventional Commits spec

This is an automatic backport of pull request #2774 done by [Mergify](https://mergify.com).

…the JSON (#2774)

This change fixes a bug in which BitArray.UnmarshalJSON hadn't accounted
for the fact that invoking NewBitArray(<=0) returns nil and hence when
dereferenced would crash with a runtime nil pointer dereference. This
bug was found by my security analysis and fuzzing too.

Author: @odeke-em

Fixes #2658

---

#### PR checklist

- [x] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] ~~Updated relevant documentation (`docs/` or `spec/`) and code
comments~~
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Emmanuel T Odeke <emmanuel@orijtech.com>
(cherry picked from commit 75d12c3)
@mergify mergify bot requested a review from a team as a code owner April 11, 2024 09:15
@mergify mergify bot requested a review from a team April 11, 2024 09:15
@melekes melekes merged commit 323ac27 into v1.x Apr 11, 2024
@melekes melekes deleted the mergify/bp/v1.x/pr-2774 branch April 11, 2024 09:26
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.

1 participant