MCPcopy Create free account
hub / github.com/GoogleChrome/samples / writeStackCookie

Function writeStackCookie

mkbitmap/mkbitmap.js:450–466  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

448// include: runtime_stack_check.js
449// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
450function writeStackCookie() {
451 var max = _emscripten_stack_get_end();
452 assert((max & 3) == 0);
453 // If the stack ends at address zero we write our cookies 4 bytes into the
454 // stack. This prevents interference with the (separate) address-zero check
455 // below.
456 if (max == 0) {
457 max += 4;
458 }
459 // The stack grow downwards towards _emscripten_stack_get_end.
460 // We write cookies to the final two words in the stack and detect if they are
461 // ever overwritten.
462 HEAPU32[((max)>>2)] = 0x02135467;
463 HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
464 // Also test the global address 0 for integrity.
465 HEAPU32[0] = 0x63736d65; /* 'emsc' */
466}
467
468function checkStackCookie() {
469 if (ABORT) return;

Callers 1

mkbitmap.jsFile · 0.85

Calls 1

assertFunction · 0.70

Tested by

no test coverage detected