EVMimports.jsView |
---|
187 | 187 | */ |
188 | 188 | callDataCopy (offset, dataOffset, length) { |
189 | 189 | this.takeGas(3 + Math.ceil(length / 32) * 3) |
190 | 190 | |
191 | | - if (length) { |
| 191 | + if (length > 0 && offset >= 0 && dataOffset >= 0) { |
192 | 192 | const callData = this.kernel.environment.callData.slice(dataOffset, dataOffset + length) |
193 | 193 | this.setMemory(offset, length, callData) |
194 | 194 | } |
195 | 195 | } |
201 | 201 | * @param {integer} dataOffset the offset in the input data |
202 | 202 | */ |
203 | 203 | callDataCopy256 (offset, dataOffset) { |
204 | 204 | this.takeGas(3) |
| 205 | + |
205 | 206 | const callData = this.kernel.environment.callData.slice(dataOffset, dataOffset + 32) |
206 | 207 | this.setMemory(offset, U256_SIZE_BYTES, callData) |
207 | 208 | } |
208 | 209 | |
336 | 337 | */ |
337 | 338 | getBlockCoinbase (offset) { |
338 | 339 | this.takeGas(2) |
339 | 340 | |
340 | | - this.setMemory(offset, ADDRESS_SIZE_BYTES, this.kernel.environment.coinbase.toMemory()) |
| 341 | + this.setMemory(offset, ADDRESS_SIZE_BYTES, this.kernel.environment.block.header.coinbase) |
341 | 342 | } |
342 | 343 | |
343 | 344 | |
344 | 345 | * Get the block’s timestamp. |
603 | 604 | * @param {integer} offset the offset of the output data. |
604 | 605 | * @param {integer} length the length of the output data. |
605 | 606 | */ |
606 | 607 | return (offset, length) { |
607 | | - if (length) { |
608 | | - this.kernel.environment.returnValue = this.getMemory(offset, length).slice(0) |
609 | | - } |
| 608 | + this.kernel.environment.returnValue = this.getMemory(offset, length).slice(0) |
610 | 609 | } |
611 | 610 | |
612 | 611 | |
613 | 612 | * Halt execution and register account for later deletion giving the remaining |
620 | 619 | this.kernel.environment.gasRefund += 24000 |
621 | 620 | } |
622 | 621 | |
623 | 622 | getMemory (offset, length) { |
624 | | - return new Uint8Array(this.kernel.memory, offset, length) |
| 623 | + if (offset >= 0 && length > 0) { |
| 624 | + return new Uint8Array(this.kernel.memory, offset, length) |
| 625 | + } else { |
| 626 | + return new Uint8Array([]) |
| 627 | + } |
625 | 628 | } |
626 | 629 | |
627 | 630 | setMemory (offset, length, value) { |
628 | | - const memory = new Uint8Array(this.kernel.memory, offset, length) |
629 | | - memory.set(value) |
| 631 | + if (offset >= 0 && length > 0) { |
| 632 | + const memory = new Uint8Array(this.kernel.memory, offset, length) |
| 633 | + memory.set(value) |
| 634 | + } |
630 | 635 | } |
631 | 636 | |
632 | 637 | |
633 | 638 | * Takes gas from the tank. Only needs to check if there's gas left to be taken, |