GHSA-j39j-6gw9-jw6h: git2 has potential undefined behavior when dereferencing Buf struct
If the Buf struct is dereferenced immediately after calling new() or default() on the Buf struct, a null pointer is passed to the unsafe function slice::fromrawparts. According to the safety section documentation of the function, data must be non-null and aligned even for zero-length slices or slices of ZSTs. Thus, passing a null pointer will lead to undefined behavior.
Published Feb 4, 2026
Affected packages
git2
- Ecosystem
- Rust (crates.io)
- Affected
- < 0.20.4
- Fixed in
- 0.20.4
- Check
cargo tree -i git2
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
If the Buf struct is dereferenced immediately after calling new() or default() on the Buf struct, a null pointer is passed to the unsafe function slice::from_raw_parts. According to the safety section documentation of the function, data must be non-null and aligned even for zero-length slices or slices of ZSTs. Thus, passing a null pointer will lead to undefined behavior.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
