summaryrefslogtreecommitdiff
path: root/src/lundump.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-17 10:34:43 +0100
committerBenoit Giannangeli <giann@users.noreply.github.com>2017-03-17 10:36:57 +0100
commit0d8de3dad35216726d6f2e0b5fe333b2b7aa6d10 (patch)
tree2628ccf96713956ebf304b6443f7d39d3fa29034 /src/lundump.js
parent18631188532881934261e72321d9839ad42d1b06 (diff)
downloadfengari-0d8de3dad35216726d6f2e0b5fe333b2b7aa6d10.tar.gz
fengari-0d8de3dad35216726d6f2e0b5fe333b2b7aa6d10.tar.bz2
fengari-0d8de3dad35216726d6f2e0b5fe333b2b7aa6d10.zip
Fixed bad string length undump
Diffstat (limited to 'src/lundump.js')
-rw-r--r--src/lundump.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lundump.js b/src/lundump.js
index 70adbec..7452c43 100644
--- a/src/lundump.js
+++ b/src/lundump.js
@@ -48,6 +48,10 @@ class BytecodeParser {
return integer;
}
+ readSize_t() {
+ return this.readInteger();
+ }
+
peekInt() {
return this.dataView.getInt32(this.offset, true);
}
@@ -71,10 +75,10 @@ class BytecodeParser {
}
read8bitString(n) {
- let size = typeof n !== 'undefined' ? n : this.readByte() - 1;
+ let size = typeof n !== 'undefined' ? n : Math.max(this.readByte() - 1, 0);
- if (size === 0xFF) // TODO: test
- this.offset += this.size_tSize;
+ if (size + 1 === 0xFF)
+ size = this.readSize_t() - 1;
if (size === 0) {
return null;
@@ -89,10 +93,10 @@ class BytecodeParser {
}
readString(n) {
- let size = typeof n !== 'undefined' ? n : this.readByte() - 1;
+ let size = typeof n !== 'undefined' ? n : Math.max(this.readByte() - 1, 0);
- if (size === 0xFF) // TODO: test
- this.offset += this.size_tSize;
+ if (size + 1 === 0xFF)
+ size = this.readSize_t() - 1;
if (size === 0) {
return null;