diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-03-06 18:23:45 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-03-06 18:35:25 +0100 |
commit | 7c3fbc34aed578398b3f180a621c671ff3837cec (patch) | |
tree | e52428f7cb819fddbdc8b801ea3894306e266d85 /src/script/script.h | |
parent | 51377c2dbe0d71dad953a43187749a38010d1f1f (diff) | |
parent | a0ae79d77552d9ee67469c934458a3f3bd170858 (diff) |
Merge pull request #5510
a0ae79d Replace CBlockHeader::GetHash with call to SerializeHash (Wladimir J. van der Laan)
62b30f0 Add serialize float/double tests (Wladimir J. van der Laan)
9f4fac9 src/txmempool.cpp: make numEntries a uint32_t (Wladimir J. van der Laan)
f4e6487 src/arith_256.cpp: bigendian compatibility (Wladimir J. van der Laan)
aac3205 src/netbase.h: Fix endian in CNetAddr serialization (Wladimir J. van der Laan)
01f9c34 src/serialize.h: base serialization level endianness neutrality (Wladimir J. van der Laan)
4e853aa src/script/script.h: endian compatibility for PUSHDATA sizes (Wladimir J. van der Laan)
4f92773 src/primitives/transaction.h: endian compatibility in serialization (Wladimir J. van der Laan)
81aeb28 src/primitives/block.cpp: endian compatibility in GetHash (Wladimir J. van der Laan)
dec84ca src/net.cpp: endian compatibility in EndMessage (Wladimir J. van der Laan)
556814e src/main.cpp: endian compatibility in packet checksum check (Wladimir J. van der Laan)
3ca5852 src/hash.cpp: endian compatibility (Wladimir J. van der Laan)
4414f5f build: Endian compatibility (Wladimir J. van der Laan)
Diffstat (limited to 'src/script/script.h')
-rw-r--r-- | src/script/script.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/script/script.h b/src/script/script.h index 8b36aa2f50..ed456f5c5a 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -14,6 +14,7 @@ #include <string.h> #include <string> #include <vector> +#include "crypto/common.h" static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes @@ -416,14 +417,16 @@ public: else if (b.size() <= 0xffff) { insert(end(), OP_PUSHDATA2); - unsigned short nSize = b.size(); - insert(end(), (unsigned char*)&nSize, (unsigned char*)&nSize + sizeof(nSize)); + uint8_t data[2]; + WriteLE16(data, b.size()); + insert(end(), data, data + sizeof(data)); } else { insert(end(), OP_PUSHDATA4); - unsigned int nSize = b.size(); - insert(end(), (unsigned char*)&nSize, (unsigned char*)&nSize + sizeof(nSize)); + uint8_t data[4]; + WriteLE32(data, b.size()); + insert(end(), data, data + sizeof(data)); } insert(end(), b.begin(), b.end()); return *this; @@ -496,15 +499,14 @@ public: { if (end() - pc < 2) return false; - nSize = 0; - memcpy(&nSize, &pc[0], 2); + nSize = ReadLE16(&pc[0]); pc += 2; } else if (opcode == OP_PUSHDATA4) { if (end() - pc < 4) return false; - memcpy(&nSize, &pc[0], 4); + nSize = ReadLE32(&pc[0]); pc += 4; } if (end() - pc < 0 || (unsigned int)(end() - pc) < nSize) |