Skip to content

Commit 97dcca8

Browse files
Add advisory for git2: DiffBinaryFile::data() for empty data triggers UB
1 parent aa90516 commit 97dcca8

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

crates/git2/RUSTSEC-0000-0000.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
```toml
2+
[advisory]
3+
id = "RUSTSEC-0000-0000"
4+
package = "git2"
5+
date = "2026-06-12"
6+
url = "https://github.com/rust-lang/git2-rs/pull/1279"
7+
informational = "unsound"
8+
keywords = ["git2"]
9+
10+
[versions]
11+
patched = ["> 0.21.0"]
12+
```
13+
14+
# Potential undefined behavior when calling DiffBinaryFile::data()
15+
16+
Git diffs with binary file changes do not always include the raw data of such changes, but sometimes just report *that* a change was made (e.g. with a line `Binary files /dev/null and b/binary.pdf differ` for a new file addition). When examining such a diff, `DiffBinaryFile::data()` caused git2 to pass a null pointer to the unsafe function `slice::from_raw_parts()`. Based on the safety section documentation of function, data must be non-null even for slices of length zero. Thus, the use of a null pointer leads to undefined behavior.

0 commit comments

Comments
 (0)