mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Deprecate Memory::require(size) function. Risk of unsigned integer overflow.
This commit is contained in:
parent
439561a5fa
commit
273b0f634f
3 changed files with 7 additions and 11 deletions
|
|
@ -785,12 +785,9 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode,
|
|||
|
||||
gasMeter.commitCostBlock(gas);
|
||||
|
||||
// Require memory for the max of in and out buffers
|
||||
auto inSizeReq = m_builder.CreateAdd(inOff, inSize, "inSizeReq");
|
||||
auto outSizeReq = m_builder.CreateAdd(outOff, outSize, "outSizeReq");
|
||||
auto cmp = m_builder.CreateICmpUGT(inSizeReq, outSizeReq);
|
||||
auto sizeReq = m_builder.CreateSelect(cmp, inSizeReq, outSizeReq, "sizeReq");
|
||||
memory.require(sizeReq);
|
||||
// Require memory for in and out buffers
|
||||
memory.require(outOff, outSize); // Out buffer first as we guess it will be after the in one
|
||||
memory.require(inOff, inSize);
|
||||
|
||||
auto receiveAddress = codeAddress;
|
||||
if (inst == Instruction::CALLCODE)
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ void Memory::require(llvm::Value* _size)
|
|||
|
||||
void Memory::require(llvm::Value* _offset, llvm::Value* _size)
|
||||
{
|
||||
auto sizeRequired = m_builder.CreateAdd(_offset, _size, "sizeRequired");
|
||||
auto sizeRequired = m_builder.CreateNUWAdd(_offset, _size, "sizeRequired");
|
||||
require(sizeRequired);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,6 @@ public:
|
|||
void copyBytes(llvm::Value* _srcPtr, llvm::Value* _srcSize, llvm::Value* _srcIndex,
|
||||
llvm::Value* _destMemIdx, llvm::Value* _byteCount);
|
||||
|
||||
/// Requires this amount of memory. And counts gas fee for that memory.
|
||||
void require(llvm::Value* _size);
|
||||
|
||||
/// Requires the amount of memory to for data defined by offset and size. And counts gas fee for that memory.
|
||||
void require(llvm::Value* _offset, llvm::Value* _size);
|
||||
|
||||
|
|
@ -36,7 +33,9 @@ private:
|
|||
llvm::Function* createFunc(bool _isStore, llvm::Type* _type, GasMeter& _gasMeter);
|
||||
llvm::Function* createRequireFunc(GasMeter& _gasMeter, RuntimeManager& _runtimeManager);
|
||||
|
||||
private:
|
||||
/// Requires this amount of memory. And counts gas fee for that memory.
|
||||
void require(llvm::Value* _size);
|
||||
|
||||
llvm::GlobalVariable* m_data;
|
||||
llvm::GlobalVariable* m_size;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue