diff options
| author | 2021-12-26 18:04:37 +0100 | |
|---|---|---|
| committer | 2021-12-26 18:20:16 +0100 | |
| commit | 2bd41eb252f2d3b66753075983c6de2483da1350 (patch) | |
| tree | c8179a811e9ecd468aca17d42827b272047c3caa | |
| parent | add some fuzzing capability (diff) | |
| download | zig-sqlite-2bd41eb252f2d3b66753075983c6de2483da1350.tar.gz zig-sqlite-2bd41eb252f2d3b66753075983c6de2483da1350.tar.xz zig-sqlite-2bd41eb252f2d3b66753075983c6de2483da1350.zip | |
add tests for crashes found by fuzzing
| -rw-r--r-- | sqlite.zig | 19 |
1 files changed, 19 insertions, 0 deletions
| @@ -3198,3 +3198,22 @@ test "sqlite: empty slice" { | |||
| 3198 | try testing.expectEqualSlices(u8, "", row.?.data.data); | 3198 | try testing.expectEqualSlices(u8, "", row.?.data.data); |
| 3199 | } | 3199 | } |
| 3200 | } | 3200 | } |
| 3201 | |||
| 3202 | test "sqlite: fuzzer found crashes" { | ||
| 3203 | const test_cases = &[_]struct { | ||
| 3204 | input: []const u8, | ||
| 3205 | exp_error: anyerror, | ||
| 3206 | }{ | ||
| 3207 | .{ | ||
| 3208 | .input = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00CREATE TABLE \x80\x00\x00\x00ar(Wb)\x01", | ||
| 3209 | .exp_error = error.SQLiteError, | ||
| 3210 | }, | ||
| 3211 | }; | ||
| 3212 | |||
| 3213 | inline for (test_cases) |tc| { | ||
| 3214 | var db = try getTestDb(); | ||
| 3215 | defer db.deinit(); | ||
| 3216 | |||
| 3217 | try testing.expectError(tc.exp_error, db.exec(tc.input, .{}, .{})); | ||
| 3218 | } | ||
| 3219 | } | ||