Commit 1c1defc5 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[piexwasm] Wasm is a 32-bit system: restrict image length

Wasm is a 32-bit system, and hence uses 32-bit integers. Restrict the
input image length (a JS int) to << 32-bits (2^30 for now).

Bug: 935285
Change-Id: I2d523e49b2392fb49f8b25e9b77e8334532b5b5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1546803Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646606}
parent ff304510
......@@ -27,6 +27,9 @@ piex wasm raw image preview / thumbnail test page
}
process(resolve, reject) {
if (this.length <= 0 || this.length >= Math.pow(2, 30))
return reject(new Error('invalid image length'));
const memory = Module._malloc(this.length);
if (!memory)
return reject(new Error('image malloc failure'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment