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: Sun, 23 Jun 2013 01:13:10 +0200

Hi Avneet,

with your patch the 2004 decoding seg faults because of the restructure of union _2004_header_data. The size and order of the fields is cruical. You can rename fields but not reorder them. In this case the union is a trick to be able to read the data as char (encripted_data part) and reinterpreting this data in the same step as several fields (struct fields part). 

In the function checksum() there were some returns in the middle of the loop, which should not be there. Take a look at "Spec 5.3 paragraph 4.2 Sectionpagechecksum".

As I understand the 2004 checksum calculation it goes like this:
- 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.


// Check the CRC for the section map
{
  unsigned long seed, ckr;

  // store the section_page_checksum because in the next step this value is set to zero
  // in order to prevent to calculate a checksum of itself
  unsigned long page_checksum = ss.fields.section_page_checksum;
  ss.fields.section_page_checksum = 0;

  // Calculate the checksum of the section header data
  seed = checksum(0, &ss.data[0], 0x14);
  ss.fields.section_page_checksum = page_checksum;

  // Calculate the CRC of the page data with the previously calculated checksum as seed

  ckr  = bit_ckr32(seed, &dat->chain[dat->byte], ss.fields.comp_data_size);

 
  if (ckr != ss.fields.section_page_checksum)
    ; // :( Checsums do not match
}

I played around with this piece of code and even though I think that the general steps are correct the calculated crc was always different from the one in the system section. Maybe you can figure out what's wrong with it.


Am 22.06.2013 um 20:43 schrieb Avneet Kaur:

On 6/17/13, Till Heuschmann <address@hidden> wrote:

Conclusion:
1. Implement 32-bit CRC.
2. Add data to common_entity_handle_data.spec and rename this file.
3. Implement Section Page checksum.
4. Implement the header, section map and info with redefined specs.
5.Implement Data Sections.
6. Biggest and major conclusion: Needs Refactoring.

Good list. I can't think of anything else...

Implementation of one, three and five points are completed.
Please verify [0].
Still, it is throwing segmentation fault on testing.

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

--
Avneet Kaur
www.avneetkhasla.wordpress.com



reply via email to

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