Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zlib fuzzer #15

Merged
merged 1 commit into from Nov 10, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -0,0 +1,36 @@
const pako = require('pako')

async function fuzz (bytes) {
try {
pako.deflate(bytes)
pako.inflate(bytes)
} catch (error) {
if (!acceptable(error)) throw error
}
}

function acceptable (error) {
return (
typeof error === 'string' &&
!!expected.find(message => error.startsWith(message))
)
}

const expected = [
'buffer error',
'incorrect header check',
'unknown compression method',
'invalid window size',
'invalid distance',
'invalid block type',
'invalid code lengths',
'too many length or distance symbols',
'invalid stored block lengths',
'need dictionary',
'incorrect data check',
'invalid literal/length code',
'invalid bit length repeat',
'invalid code'
]

exports.fuzz = fuzz

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,9 @@
{
"name": "zlib-fuzz",
"version": "1.0.0",
"main": "fuzz.js",
"license": "ISC",
"dependencies": {
"pako": "^1.0.10"
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.