This repository was archived by the owner on Apr 30, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +33
-2
lines changed Expand file tree Collapse file tree 5 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 1+ # These are supported funding model platforms
2+
3+ github : yevgenypats
4+
Original file line number Diff line number Diff line change @@ -148,5 +148,6 @@ any unnecessary work is done.
148148* [ js-yaml: Crash/TypeError] ( https://github.com/nodeca/js-yaml/issues/525 )
149149* [ asciidoctor: Hang/DoS] ( https://github.com/asciidoctor/asciidoctor/issues/3472 )
150150* [ deanm/omggif: Crash/TypeError] ( https://github.com/deanm/omggif/issues/41 )
151+ * [ Leonidas-from-XIV/node-xml2js: Crash/TypeError] ( https://github.com/Leonidas-from-XIV/node-xml2js/issues/544 )
151152
152153** Feel free to add bugs that you found with jsfuzz to this list via pull-request**
Original file line number Diff line number Diff line change @@ -13,9 +13,11 @@ export class Corpus {
1313 private corpusPath : string | undefined ;
1414 private maxInputSize : number ;
1515 private seedLength : number ;
16+ private readonly onlyAscii : boolean ;
1617
17- constructor ( dir : string [ ] ) {
18+ constructor ( dir : string [ ] , onlyAscii : boolean ) {
1819 this . inputs = [ ] ;
20+ this . onlyAscii = onlyAscii ;
1921 this . maxInputSize = 4096 ;
2022 for ( let i of dir ) {
2123 if ( ! fs . existsSync ( i ) ) {
@@ -106,6 +108,16 @@ export class Corpus {
106108 }
107109 }
108110
111+ toAscii ( buf : Buffer ) {
112+ let x ;
113+ for ( let i = 0 ; i < buf . length ; i ++ ) {
114+ x = buf [ i ] & 127 ;
115+ if ( ( x < 0x20 || x > 0x7E ) && x !== 0x09 && ( x < 0xA || x > 0xD ) ) {
116+ buf [ i ] = 0x20 ;
117+ }
118+ }
119+ }
120+
109121 mutate ( buf : Buffer ) {
110122 let res = Buffer . allocUnsafe ( buf . length ) ;
111123 buf . copy ( res , 0 , 0 , buf . length ) ;
@@ -341,6 +353,11 @@ export class Corpus {
341353 if ( res . length > this . maxInputSize ) {
342354 res = res . slice ( 0 , this . maxInputSize )
343355 }
356+
357+ if ( this . onlyAscii ) {
358+ this . toAscii ( res ) ;
359+ }
360+
344361 return res ;
345362 }
346363}
Original file line number Diff line number Diff line change @@ -33,16 +33,19 @@ export class Fuzzer {
3333 private regression : boolean ;
3434 private verse : Verse | null ;
3535 private readonly versifier : boolean ;
36+ private readonly onlyAscii : boolean ;
3637
3738 constructor ( target : string ,
3839 dir : string [ ] ,
3940 exactArtifactPath : string ,
4041 rssLimitMb : number ,
4142 timeout : number ,
4243 regression : boolean ,
44+ onlyAscii : boolean ,
4345 versifier : boolean ) {
4446 this . target = target ;
45- this . corpus = new Corpus ( dir ) ;
47+ this . corpus = new Corpus ( dir , onlyAscii ) ;
48+ this . onlyAscii = onlyAscii ;
4649 this . versifier = versifier ;
4750 this . verse = null ;
4851 this . total_executions = 0 ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ function startFuzzer(argv: any) {
1010 argv . rssLimitMb ,
1111 argv . timeout ,
1212 argv . regression ,
13+ argv . onlyAscii ,
1314 argv . versifier ) ;
1415 fuzzer . start ( )
1516}
@@ -56,5 +57,10 @@ require('yargs')
5657 description : 'use versifier algorithm (good for text based protocols)' ,
5758 default : true ,
5859 } )
60+ . option ( 'only-ascii' , {
61+ type : 'boolean' ,
62+ description : 'generate only ASCII (isprint+isspace) inputs' ,
63+ default : false ,
64+ } )
5965 . help ( )
6066 . argv ;
You can’t perform that action at this time.
0 commit comments