libredwg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libredwg] Decode R2004 version


From: Till Heuschmann
Subject: Re: [libredwg] Decode R2004 version
Date: Wed, 03 Jul 2013 22:27:33 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7

It was my fault, when I first looked at your patch I have overread that you not only reordered
the fields but resized some of them from 32 Bit to 64 Bit. In combination that is correct!

When you now do a sizeof(_2004_header_data) it will return 118 Bytes on a 64 Bit platform.
Calculating the size of the struct by "hand" will result in 108 Bytes. Actually the compiler aligns
the fields in a different way so that 4 Bytes are wasted.

Write the struct definition like this:

#pragma pack(push,2)
    union
    {
        unsigned char encripted_data[0x6c];
        ...
    } _2004_header_data;
#pragma pack(pop)

This will force the compiler to align the fields at a 2 Byte boundary and a sizeof(_2004_header_data) will result in 108 Bytes.

On a 32 Bit platform the "unsigned long int" type is 4 Bytes wide not 8 Bytes!

To get save with this use the int64_t type for 8 Byte types and int32_t for 4 Byte types, like the structs in decode_R2007.c.



Am 03.07.2013 08:11, schrieb Avneet Kaur:
On Sun, Jun 23, 2013 at 4:43 AM, Till Heuschmann <address@hidden> wrote:
- There is the system_section union the section_page_checksum is the value
that the calculated checksum must be compared with.
- Calculate the checksum of the section header data (this is the
system_section union ss) with a seed of 0.
- Calculate the crc32 of the section data with the previously calculated
checksum as seed.

Please check this [0], still getting same error "segfault".

[0]: http://202.164.53.122/~avneet/2004.patch


--
Avneet Kaur
www.avneetkhasla.wordpress.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]