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

Commit 93ce761

Browse files
author
Yevgeny Pats
committed
bugfix in resume from corpus/seed
1 parent 3793e8b commit 93ce761

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

examples/zlib/fuzz.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const expected = [
3030
'incorrect data check',
3131
'invalid literal/length code',
3232
'invalid bit length repeat',
33-
'invalid code'
34-
]
33+
'invalid code',
34+
'invalid literal'
35+
];
3536

36-
exports.fuzz = fuzz
37+
exports.fuzz = fuzz;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsfuzz",
3-
"version": "1.0.12",
3+
"version": "1.0.13",
44
"description": "Coverage Guided Javascript Fuzzer",
55
"main": "build/src/index.js",
66
"types": "build/src/inde.d.ts",

src/corpus.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@ import {uint16, uint32} from "./math";
44
var crypto = require('crypto');
55

66
const INTERESTING8 = new Uint8Array([-128, -1, 0, 1, 16, 32, 64, 100, 127]);
7-
const INTERESTING16 = new Uint16Array([-32768, -129, 128, 255, 256, 512, 1000, 1024, 4096, 32767]);
8-
const INTERESTING32 = new Uint32Array([-2147483648, -100663046, -32769, 32768, 65535, 65536, 100663045, 2147483647]);
7+
const INTERESTING16 = new Uint16Array([-32768, -129, 128, 255, 256, 512, 1000, 1024, 4096, 32767, -128, -1, 0, 1, 16, 32, 64, 100, 127]);
8+
const INTERESTING32 = new Uint32Array([-2147483648, -100663046, -32769, 32768, 65535, 65536, 100663045, 2147483647, -32768, -129, 128, 255, 256, 512, 1000, 1024, 4096, 32767]);
99

1010

1111
export class Corpus {
1212
private inputs: Buffer[];
1313
private seedPath: string | undefined;
1414
private corpusPath: string | undefined;
1515
private maxInputSize: number;
16+
private seedLength: number;
1617

1718
constructor(dir: string[]) {
1819
this.inputs = [];
1920
this.maxInputSize = 4096;
2021
for (let i of dir) {
22+
if (!fs.existsSync(i)) {
23+
fs.mkdirSync(i);
24+
}
2125
if (fs.lstatSync(i).isDirectory()) {
2226
if (!this.corpusPath) {
2327
this.corpusPath = i;
@@ -27,6 +31,7 @@ export class Corpus {
2731
this.inputs.push(fs.readFileSync(i));
2832
}
2933
}
34+
this.seedLength = this.inputs.length;
3035

3136
}
3237

@@ -42,8 +47,12 @@ export class Corpus {
4247
}
4348

4449
generateInput() {
50+
if (this.seedLength > 0) {
51+
this.seedLength -= 1;
52+
return this.inputs[this.seedLength];
53+
}
4554
if (this.inputs.length === 0) {
46-
const buf = Buffer.alloc(0, 0)
55+
const buf = Buffer.alloc(0, 0);
4756
this.putBuffer(buf);
4857
return buf;
4958
}

0 commit comments

Comments
 (0)