summaryrefslogtreecommitdiff
path: root/lib/buffer.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-01-17 23:08:52 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-01-24 13:12:51 +0100
commit7a23fc076045e767b922343c226d8492cc98cb93 (patch)
tree8c10c51a4c4e885566440a15b5eab7d6fb0ef1b4 /lib/buffer.js
parent373e893ee0f09108289f623f73213907b8b05889 (diff)
downloadandroid-node-v8-7a23fc076045e767b922343c226d8492cc98cb93.tar.gz
android-node-v8-7a23fc076045e767b922343c226d8492cc98cb93.tar.bz2
android-node-v8-7a23fc076045e767b922343c226d8492cc98cb93.zip
buffer: coerce offset to integer
The offset was formerly coerced to a integer and this reimplements that. PR-URL: https://github.com/nodejs/node/pull/18215 Fixes: https://github.com/nodejs/node/issues/18208 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'lib/buffer.js')
-rw-r--r--lib/buffer.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index 75b8cedd1d..4b800039fe 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -1272,6 +1272,7 @@ function toFloat(x) {
Buffer.prototype.readDoubleBE = function(offset, noAssert) {
+ offset = offset >>> 0;
const x1 = this.readUInt32BE(offset + 0, noAssert);
const x0 = this.readUInt32BE(offset + 4, noAssert);
return toDouble(x0, x1);
@@ -1279,6 +1280,7 @@ Buffer.prototype.readDoubleBE = function(offset, noAssert) {
Buffer.prototype.readDoubleLE = function(offset, noAssert) {
+ offset = offset >>> 0;
const x0 = this.readUInt32LE(offset + 0, noAssert);
const x1 = this.readUInt32LE(offset + 4, noAssert);
return toDouble(x0, x1);
@@ -1286,11 +1288,13 @@ Buffer.prototype.readDoubleLE = function(offset, noAssert) {
Buffer.prototype.readFloatBE = function(offset, noAssert) {
+ offset = offset >>> 0;
return toFloat(this.readUInt32BE(offset, noAssert));
};
Buffer.prototype.readFloatLE = function(offset, noAssert) {
+ offset = offset >>> 0;
return toFloat(this.readUInt32LE(offset, noAssert));
};