MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fuzz

Function fuzz

xs/tools/xstFuzz.c:447–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445#endif
446
447int fuzz(int argc, char* argv[])
448{
449 char helo[] = "HELO";
450 if (4 != write(REPRL_CWFD, helo, 4)) {
451 fprintf(stderr, "Error writing HELO\n");
452 c_exit(-1);
453 }
454 if (4 != read(REPRL_CRFD, helo, 4)) {
455 fprintf(stderr, "Error reading HELO\n");
456 c_exit(-1);
457 }
458 if (0 != memcmp(helo, "HELO", 4)) {
459 fprintf(stderr, "Invalid response from parent\n");
460 c_exit(-1);
461 }
462 xsCreation _creation = {
463 1 * 1024 * 1024, /* initialChunkSize */
464 1 * 1024 * 1024, /* incrementalChunkSize */
465 32768, /* initialHeapCount */
466 32768, /* incrementalHeapCount */
467 64 * 1024, /* stackCount */
468 1024, /* initialKeyCount */
469 1024, /* incrementalKeyCount */
470 1993, /* nameModulo */
471 127, /* symbolModulo */
472 64 * 1024, /* parserBufferSize */
473 1993, /* parserTableModulo */
474 };
475
476 while (1) {
477 int error = 0;
478 char *buffer = NULL;
479
480 gxStress = 0;
481 gxMemoryFail = 0;
482
483 xsMachine* machine = xsCreateMachine(&_creation, "xst_fuzz", NULL);
484 xsBeginMetering(machine, xsAlwaysWithinComputeLimit, 0); // interval/step of zero means "never invoke callback"
485 {
486 xsBeginHost(machine);
487 {
488 xsTry {
489 xsVars(1);
490
491 // hardened javascript
492 xsResult = xsNewHostFunction(fx_harden, 1);
493 xsDefine(xsGlobal, xsID("harden"), xsResult, xsDontEnum);
494 xsResult = xsNewHostFunction(fx_lockdown, 0);
495 xsDefine(xsGlobal, xsID("lockdown"), xsResult, xsDontEnum);
496 xsResult = xsNewHostFunction(fx_petrify, 1);
497 xsDefine(xsGlobal, xsID("petrify"), xsResult, xsDontEnum);
498 xsResult = xsNewHostFunction(fx_mutabilities, 1);
499 xsDefine(xsGlobal, xsID("mutabilities"), xsResult, xsDontEnum);
500
501 // fuzzilli
502 xsResult = xsNewHostFunction(fx_fuzzilli, 2);
503 xsSet(xsGlobal, xsID("fuzzilli"), xsResult);
504 xsResult = xsNewHostFunction(fx_fuzz_gc, 0);

Callers 1

mainFunction · 0.85

Calls 13

modInstallTextDecoderFunction · 0.85
modInstallTextEncoderFunction · 0.85
fxBundleIsFunction · 0.85
fxBundleRunFunction · 0.85
fxRunScriptFunction · 0.85
fxRunLoopFunction · 0.85
fxBundleMapResetFunction · 0.85
fxDeleteScriptFunction · 0.85
fxParseScriptFunction · 0.70
writeFunction · 0.50

Tested by

no test coverage detected