Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I0d532eb84d122e39ce71e94b4760b94cd636eeea
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1691
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit
b5b56a2239369e45d7fac2ea965558a1f337b602)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205091
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
(cherry picked from commit
a20ae7b5f80a45e49a47ce22f5e92749cd9816a0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205101
Gbp-Pq: Name CVE-2026-8358.diff
sal_uLong AddLoadedGenerated( const ScCellValue& rNewCell,
const ScBigRange& aBigRange, const OUString& sNewValue ); // only to use in the XML import
- void AppendLoaded( std::unique_ptr<ScChangeAction> pAppend ); // this is only for the XML import public, it should be protected
+ // returns false if the action number is already in use, in which case the new duplicate is dropped
+ bool AppendLoaded( std::unique_ptr<ScChangeAction> pAppend ); // this is only for the XML import public, it should be protected
void SetActionMax(sal_uLong nTempActionMax)
{ nActionMax = nTempActionMax; } // only to use in the XML import
}
}
-void ScChangeTrack::AppendLoaded( std::unique_ptr<ScChangeAction> pActionParam )
+bool ScChangeTrack::AppendLoaded( std::unique_ptr<ScChangeAction> pActionParam )
{
+ auto [it, inserted] = aMap.insert(std::make_pair(pActionParam->GetActionNumber(), pActionParam.get()));
+ if (!inserted)
+ return false;
ScChangeAction* pAppend = pActionParam.release();
- aMap.insert( ::std::make_pair( pAppend->GetActionNumber(), pAppend ) );
if ( !pLast )
pFirst = pLast = pAppend;
else
pLast = pAppend;
}
MasterLinks( pAppend );
+ return true;
}
void ScChangeTrack::Append( ScChangeAction* pAppend, sal_uLong nAction )
// old files didn't store nanoseconds, disable until encountered
pTrack->SetTimeNanoSeconds( false );
- for (const auto & rAction : aActions)
+ auto aItr = aActions.begin();
+ while (aItr != aActions.end())
{
+ const auto& rAction = *aItr;
std::unique_ptr<ScChangeAction> pAction;
switch (rAction->nActionType)
}
}
- if (pAction)
- pTrack->AppendLoaded(std::move(pAction));
+ // Malformed documents can repeat the same XML id across actions. If
+ // this happens drop entries whose action number is already in the track.
+ if (pAction && pTrack->AppendLoaded(std::move(pAction)))
+ ++aItr;
else
{
- OSL_FAIL("no action");
+ SAL_WARN("sc.filter", "Dropping malformed change track entry");
+ aItr = aActions.erase(aItr);
}
}
if (pTrack->GetLast())
pTrack->SetActionMax(pTrack->GetLast()->GetActionNumber());
- auto aItr = aActions.begin();
+ aItr = aActions.begin();
while (aItr != aActions.end())
{
SetDependencies(aItr->get(), *pDoc);