| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,12 +74,12 @@ const advanced = { | |||
| 74 | 74 | while (messageBufferHead.length >= 4) { | |
| 75 | 75 | // We call `readUInt32BE` manually here, because this is faster than first converting | |
| 76 | 76 | // it to a buffer and using `readUInt32BE` on that. | |
| 77 | - const fullMessageSize = ( | ||
| 77 | + const fullMessageSize = (( | ||
| 78 | 78 | messageBufferHead[0] << 24 | | |
| 79 | 79 | messageBufferHead[1] << 16 | | |
| 80 | 80 | messageBufferHead[2] << 8 | | |
| 81 | 81 | messageBufferHead[3] | |
| 82 | - ) + 4; | ||
| 82 | + ) >>> 0) + 4; | ||
| 83 | 83 | ||
| 84 | 84 | if (channel[kMessageBufferSize] < fullMessageSize) break; | |
| 85 | 85 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,42 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const { fork } = require('child_process'); | ||
| 5 | + const fs = require('fs'); | ||
| 6 | + | ||
| 7 | + if (process.argv[2] === 'child-buffer') { | ||
| 8 | + const v = process.argv[3]; | ||
| 9 | + const payload = Buffer.from([ | ||
| 10 | + (v >> 24) & 0xFF, | ||
| 11 | + (v >> 16) & 0xFF, | ||
| 12 | + (v >> 8) & 0xFF, | ||
| 13 | + v & 0xFF, | ||
| 14 | + ]); | ||
| 15 | + const fd = process.channel?.fd; | ||
| 16 | + if (fd === undefined) { | ||
| 17 | + // skip test | ||
| 18 | + process.exit(0); | ||
| 19 | + } | ||
| 20 | + fs.writeSync(fd, payload); | ||
| 21 | + return; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + const testCases = [ | ||
| 25 | + 0x00000001, | ||
| 26 | + 0x7fffffff, | ||
| 27 | + 0x80000000, | ||
| 28 | + 0x80000001, | ||
| 29 | + 0xffffffff, | ||
| 30 | + ]; | ||
| 31 | + | ||
| 32 | + for (const size of testCases) { | ||
| 33 | + const child = fork(__filename, ['child-buffer', size], { | ||
| 34 | + serialization: 'advanced', | ||
| 35 | + stdio: ['inherit', 'inherit', 'inherit', 'ipc'], | ||
| 36 | + }); | ||
| 37 | + | ||
| 38 | + child.on('exit', common.mustCall((code, signal) => { | ||
| 39 | + assert.strictEqual(code, 0); | ||
| 40 | + assert.strictEqual(signal, null); | ||
| 41 | + })); | ||
| 42 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments