From 4bc8d8e4ddb353bab142ae30ad2a31f9a272b4c1 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Wed, 7 Oct 2026 12:44:21 +0200 Subject: [PATCH] tdf#173869: Compound File Binary version 4 rejected - PPT/DOC fail to load Bugtracker submitted but also analyzed and with suggestion of a fix by Florian Stascheck (florian.stascheck@gmail.com) (see bugtracker for the whole analysis) Thank you to him! Edit: m_nPageSize is in fact the sector shift (see https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cfb/05060311-bfce-4b12-874d-71fd4ce63aea) so name the constants accordingly. Change-Id: Iccbad515c0cda243e1ed9eec12caf7b614215484 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211958 Tested-by: Jenkins Reviewed-by: Julien Nabet --- sot/source/sdstor/stgelem.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sot/source/sdstor/stgelem.cxx b/sot/source/sdstor/stgelem.cxx index a4d06eb55d5a..23f133c70e9b 100644 --- a/sot/source/sdstor/stgelem.cxx +++ b/sot/source/sdstor/stgelem.cxx @@ -193,9 +193,11 @@ static bool isKnownSpecial(sal_Int32 nLocation) // Perform thorough checks also on unknown variables bool StgHeader::Check() { + constexpr sal_Int16 SECTOR_SHIFT_V3 = 9; // 2^9 = 512 bytes per sector + constexpr sal_Int16 SECTOR_SHIFT_V4 = 12; // 2^12 = 4096 bytes per sector + short version = static_cast( m_nVersion >> 16 ); return memcmp( m_cSignature, cStgSignature, 8 ) == 0 - && static_cast( m_nVersion >> 16 ) == 3 - && m_nPageSize == 9 + && ((version == 3 && m_nPageSize == SECTOR_SHIFT_V3) || (version == 4 && m_nPageSize == SECTOR_SHIFT_V4)) && lcl_wontoverflow(m_nPageSize) && lcl_wontoverflow(m_nDataPageSize) && m_nFATSize > 0