|
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:
|
[Prev in Thread] | Current Thread | [Next in Thread] |