Skip to content
This repository was archived by the owner on Apr 30, 2021. It is now read-only.

Commit 9c9211a

Browse files
committed
Add gif fuzzer
1 parent 3a56a38 commit 9c9211a

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

examples/gif/fuzz.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const omggif = require('omggif')
2+
3+
async function fuzz (bytes) {
4+
try {
5+
omggif.GifReader(bytes)
6+
} catch (error) {
7+
if (!acceptable(error)) throw error
8+
}
9+
}
10+
11+
function acceptable (error) {
12+
return !!expected
13+
.find(message => error.message.startsWith(message))
14+
}
15+
16+
const expected = [
17+
'Invalid GIF 87a/89a header',
18+
'Unknown gif block',
19+
'Invalid block size',
20+
'Invalid graphics extension block',
21+
'Unknown graphic control label'
22+
]
23+
24+
exports.fuzz = fuzz

examples/gif/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/gif/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "gif-fuzz",
3+
"version": "1.0.0",
4+
"main": "fuzz.js",
5+
"license": "ISC",
6+
"dependencies": {
7+
"omggif": "^1.0.10"
8+
}
9+
}

0 commit comments

Comments
 (0)