Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jfuzz fuzz target script for WebAssembly parsing library
const parser = require("@webassemblyjs/wasm-parser");
function fuzz(buf) {
try {
parser.decode(buf, {});
} catch (e) {
// Those are "valid" exceptions. we can't catch them in one line as
if (e.message.indexOf('Unexpected section') !== -1 ||
e.message.indexOf('Atomic instructions') !== -1 ||
e.message.indexOf('unknown table') !== -1 ||
e.message.indexOf('Internal failure') !== -1 ||
e.message.indexOf('Unexpected ') !== -1 ||
e.message.indexOf('magic header') !== -1 ||
e.message.indexOf('Unexpected') !== -1 ||
e.message.indexOf('typeof') !== -1 ||
e.message.indexOf('integer') !== -1 ||
e.message.indexOf('Unknown') !== -1 ||
e.message.indexOf('Unsupported') !== -1 ||
e.message.indexOf('data section') !== -1 ||
e.message.indexOf('unknown') !== -1 ||
e.message.indexOf('zero flag expected') !== -1 ||
e.message.indexOf('invalid UTF-8') !== -1 ||
e.message.indexOf('function signature') !== -1
) {}
else { throw e; }
}
}
module.exports = {
fuzz
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.