From 21a875de14c06d1984bdb827212d4c39aa7ac716 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Tue, 23 Oct 2018 16:16:33 +0300 Subject: [PATCH] Fix short address decoding Example addresses: ``` 0x0014F55A50b281EFD12294f0Cda821Bd8171e920 0x0000000000000000000000000000000000000000 ``` --- contracts/lib/RLP.sol | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/contracts/lib/RLP.sol b/contracts/lib/RLP.sol index 77019fa..36d206d 100644 --- a/contracts/lib/RLP.sol +++ b/contracts/lib/RLP.sol @@ -306,13 +306,10 @@ library RLP { view returns (address data) { - require(isData(self)); - var (rStartPos, len) = _decode(self); - if (len != 20) + var (, len) = _decode(self); + if (len > 20) throw; - assembly { - data := div(mload(rStartPos), exp(256, 12)) - } + return address(toUint(self)); } // Get the payload offset. @@ -444,4 +441,4 @@ library RLP { return false; return true; } -} \ No newline at end of file +}