guest271314/native-messaging-quickjs

Length conversion looks wrong

evilpie opened this issue · 0 comments

https://github.com/guest271314/native-messaaging-quickjs/blob/5e77021e5120865cc647e3197dc856abb16db4d9/nm_qjs.js#L11

This Uint32Array only has one element so the reduce isn't doing anything. I think you could replace the whole code with:

const header = new Uint32Array(1);
std.in.read(header.buffer, 0, header.byteLength);
// https://stackoverflow.com/a/26140545
const length = header[0];