Skip to content

Commit 34e9863

Browse files
authored
Merge pull request #809 from weiznich/master
Report use-after-free issue in diesels sqlite backend
2 parents 68ccfc5 + c31f016 commit 34e9863

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

crates/diesel/RUSTSEC-0000-0000.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
```toml
2+
[advisory]
3+
id = "RUSTSEC-0000-0000"
4+
package = "diesel"
5+
date = "2021-03-05"
6+
url = "https://github.com/diesel-rs/diesel/pull/2663"
7+
categories = ["memory-corruption"]
8+
keywords = ["use after free"]
9+
10+
[affected]
11+
functions = { "diesel::SqliteConnection::query_by_name" = ["< 1.4.6"] }
12+
[versions]
13+
patched = [">= 1.4.6"]
14+
```
15+
16+
# Fix a use-after-free bug in diesels Sqlite backend
17+
18+
We've misused `sqlite3_column_name`. The
19+
[SQLite](https://www.sqlite.org/c3ref/column_name.html) documentation
20+
states that the following:
21+
22+
> The returned string pointer is valid until either the prepared statement
23+
> is destroyed by sqlite3_finalize() or until the statement is automatically
24+
> reprepared by the first call to sqlite3_step() for a particular
25+
> run or until the next call to sqlite3_column_name()
26+
> or sqlite3_column_name16() on the same column.
27+
28+
As part of our `query_by_name` infrastructure we've first received all
29+
field names for the prepared statement and stored them as string slices
30+
for later use. After that we called `sqlite3_step()` for the first time,
31+
which invalids the pointer and therefore the stored string slice.

0 commit comments

Comments
 (0)