mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +00:00
fix endianess bug in LZMA decoding
This commit is contained in:
parent
ba6ca031bb
commit
165986841e
2
makefile
2
makefile
@ -328,7 +328,7 @@ ifeq ($(platform),darwin)
|
|||||||
version-script-flag =
|
version-script-flag =
|
||||||
lflags = $(common-lflags) -ldl -framework CoreFoundation
|
lflags = $(common-lflags) -ldl -framework CoreFoundation
|
||||||
|
|
||||||
ifeq (,$(shell ld -v | grep cctools))
|
ifeq (,$(shell ld -v 2>&1 | grep cctools))
|
||||||
lflags += -Wl,-compatibility_version,1.0.0
|
lflags += -Wl,-compatibility_version,1.0.0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -13,6 +13,19 @@
|
|||||||
|
|
||||||
using namespace vm;
|
using namespace vm;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
int32_t
|
||||||
|
read4(const uint8_t* in)
|
||||||
|
{
|
||||||
|
return (static_cast<int32_t>(in[3]) << 24)
|
||||||
|
| (static_cast<int32_t>(in[2]) << 16)
|
||||||
|
| (static_cast<int32_t>(in[1]) << 8)
|
||||||
|
| (static_cast<int32_t>(in[0]) );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace vm {
|
namespace vm {
|
||||||
|
|
||||||
uint8_t*
|
uint8_t*
|
||||||
@ -22,8 +35,7 @@ decodeLZMA(System* s, Allocator* a, uint8_t* in, unsigned inSize,
|
|||||||
const unsigned PropHeaderSize = 5;
|
const unsigned PropHeaderSize = 5;
|
||||||
const unsigned HeaderSize = 13;
|
const unsigned HeaderSize = 13;
|
||||||
|
|
||||||
int32_t outSize32;
|
int32_t outSize32 = read4(in + PropHeaderSize);
|
||||||
memcpy(&outSize32, in + PropHeaderSize, 4);
|
|
||||||
expect(s, outSize32 >= 0);
|
expect(s, outSize32 >= 0);
|
||||||
SizeT outSizeT = outSize32;
|
SizeT outSizeT = outSize32;
|
||||||
|
|
||||||
|
@ -41,6 +41,15 @@ extern "C" {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
int32_t
|
||||||
|
read4(const uint8_t* in)
|
||||||
|
{
|
||||||
|
return (static_cast<int32_t>(in[3]) << 24)
|
||||||
|
| (static_cast<int32_t>(in[2]) << 16)
|
||||||
|
| (static_cast<int32_t>(in[1]) << 8)
|
||||||
|
| (static_cast<int32_t>(in[0]) );
|
||||||
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
myAllocate(void*, size_t size)
|
myAllocate(void*, size_t size)
|
||||||
{
|
{
|
||||||
@ -127,8 +136,7 @@ main(int ac, const char** av)
|
|||||||
|
|
||||||
SizeT inSize = SYMBOL(end) - SYMBOL(start);
|
SizeT inSize = SYMBOL(end) - SYMBOL(start);
|
||||||
|
|
||||||
int32_t outSize32;
|
int32_t outSize32 = read4(SYMBOL(start) + PropHeaderSize);
|
||||||
memcpy(&outSize32, SYMBOL(start) + PropHeaderSize, 4);
|
|
||||||
SizeT outSize = outSize32;
|
SizeT outSize = outSize32;
|
||||||
|
|
||||||
uint8_t* out = static_cast<uint8_t*>(malloc(outSize));
|
uint8_t* out = static_cast<uint8_t*>(malloc(outSize));
|
||||||
|
@ -17,6 +17,15 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
int32_t
|
||||||
|
read4(const uint8_t* in)
|
||||||
|
{
|
||||||
|
return (static_cast<int32_t>(in[3]) << 24)
|
||||||
|
| (static_cast<int32_t>(in[2]) << 16)
|
||||||
|
| (static_cast<int32_t>(in[1]) << 8)
|
||||||
|
| (static_cast<int32_t>(in[0]) );
|
||||||
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
myAllocate(void*, size_t size)
|
myAllocate(void*, size_t size)
|
||||||
{
|
{
|
||||||
@ -100,8 +109,7 @@ main(int argc, const char** argv)
|
|||||||
if (encode) {
|
if (encode) {
|
||||||
outSize = size * 2;
|
outSize = size * 2;
|
||||||
} else {
|
} else {
|
||||||
int32_t outSize32;
|
int32_t outSize32 = read4(data + PropHeaderSize);
|
||||||
memcpy(&outSize32, data + PropHeaderSize, 4);
|
|
||||||
if (outSize32 >= 0) {
|
if (outSize32 >= 0) {
|
||||||
outSize = outSize32;
|
outSize = outSize32;
|
||||||
} else if (argc == 5) {
|
} else if (argc == 5) {
|
||||||
|
Loading…
Reference in New Issue
Block a user