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

Commit dfe7f3c

Browse files
author
Yevgeny Pats
authored
Merge pull request #14 from bookmoons/gif
Add GIF fuzzer
2 parents 3a56a38 + 36e315c commit dfe7f3c

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,6 @@ any unnecessary work is done.
147147
* [js-yaml: Crash/TypeError](https://github.com/nodeca/js-yaml/issues/524)
148148
* [js-yaml: Crash/TypeError](https://github.com/nodeca/js-yaml/issues/525)
149149
* [asciidoctor: Hang/DoS](https://github.com/asciidoctor/asciidoctor/issues/3472)
150+
* [deanm/omggif: Crash/TypeError](https://github.com/deanm/omggif/issues/41)
150151

151152
**Feel free to add bugs that you found with jsfuzz to this list via pull-request**

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)