aboutsummaryrefslogtreecommitdiff
path: root/src/node_buffer.cc
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-01-18 12:58:16 -0800
committerisaacs <i@izs.me>2013-01-18 12:58:16 -0800
commit3d7818fc42c5f9af2aeccf9d75ad6a2372179f28 (patch)
treedc768380326c509df5d90616bdfcbfb6d22b6264 /src/node_buffer.cc
parentfc3547bc828dfcaca83e9c4415743fb201a821f6 (diff)
parent9c2c84546347df599840aceb59605b4b6d38a549 (diff)
downloadandroid-node-v8-3d7818fc42c5f9af2aeccf9d75ad6a2372179f28.tar.gz
android-node-v8-3d7818fc42c5f9af2aeccf9d75ad6a2372179f28.tar.bz2
android-node-v8-3d7818fc42c5f9af2aeccf9d75ad6a2372179f28.zip
Merge remote-tracking branch 'ry/v0.8' into master
Conflicts: AUTHORS ChangeLog src/node_version.h test/simple/test-buffer.js
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r--src/node_buffer.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index ed2656955a..58f83d8d59 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -857,6 +857,19 @@ Handle<Value> Buffer::MakeFastBuffer(const Arguments &args) {
uint32_t offset = args[2]->Uint32Value();
uint32_t length = args[3]->Uint32Value();
+ if (offset > buffer->length_) {
+ return ThrowRangeError("offset out of range");
+ }
+
+ if (offset + length > buffer->length_) {
+ return ThrowRangeError("length out of range");
+ }
+
+ // Check for wraparound. Safe because offset and length are unsigned.
+ if (offset + length < offset) {
+ return ThrowRangeError("offset or length out of range");
+ }
+
fast_buffer->SetIndexedPropertiesToExternalArrayData(buffer->data_ + offset,
kExternalUnsignedByteArray,
length);