https://bugs.documentfoundation.org/show_bug.cgi?id=173869

--- Comment #4 from Florian Stascheck <[email protected]> ---
(In reply to Julien Nabet from comment #3)
> Just for the record, even with this patch:
> diff --git a/sot/source/sdstor/stgelem.cxx b/sot/source/sdstor/stgelem.cxx
> index a4d06eb55d5a..37c1b493e8ac 100644
> --- a/sot/source/sdstor/stgelem.cxx
> +++ b/sot/source/sdstor/stgelem.cxx
> @@ -193,8 +193,9 @@ static bool isKnownSpecial(sal_Int32 nLocation)
>  // Perform thorough checks also on unknown variables
>  bool StgHeader::Check()
>  {
> +    short version = static_cast<short>( m_nVersion >> 16 );
>      return  memcmp( m_cSignature, cStgSignature, 8 ) == 0
> -            && static_cast<short>( m_nVersion >> 16 ) == 3
> +            && (version == 3 || version == 4)
>              && m_nPageSize == 9
>              && lcl_wontoverflow(m_nPageSize)
>              && lcl_wontoverflow(m_nDataPageSize)
> 
> it still doesn't work.

Thanks for testing!

That patch only relaxes the version check, but the next line still requires
m_nPageSize == 9. In a v4 file the sector shift is 12 (2^12 = 4096-byte
sectors), so Check() still fails and type detection falls through to the other
filters (hence the MacPaint/WPS probes in your log). For the attached
test-v4.ppt the header has major version 4 and sector shift 12 (offset 0x1E =
0x000C).

Version and sector size have to be checked together:

-            && static_cast<short>( m_nVersion >> 16 ) == 3
-            && m_nPageSize == 9
+            && ( ( static_cast<short>( m_nVersion >> 16 ) == 3 && m_nPageSize
== 9 )
+              || ( static_cast<short>( m_nVersion >> 16 ) == 4 && m_nPageSize
== 12 ) )

>From reading the code (I haven't built it), the rest of the read path looks
sector-size-agnostic: StgIo::SetupStreams() calls SetPhysPageSize(1 <<
GetPageSize()), StgCache::Page2Pos() returns nPage * m_nPageSize + m_nPageSize
(correct for v4, where the header occupies a full 4096-byte sector), and the
FAT/directory code in stgstrms.cxx derives everything from m_nPageSize. One
small thing: lcl_GetPageCount() subtracts a fixed 512 for the header, so for v4
it counts one page too many. Reading that phantom page should just hit EOF, but
it may be worth fixing at the same time.

Could you give it another try with both conditions changed?

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to