Bug 1937978 - Exit early with success when decrypting an empty CBCS subsample buffer with ClearKey. r=media-playback-reviewers,aosmond

Without the early exit, DecryptCbcs() will try to get the address of the first
element in the subsample (Span), which with length 0 is forbidden.

This could also be solved by getting the address of the Span through data()
instead, to avoid dereferencing the first element. That seems more like a
footgun than the early exit however.

Differential Revision: https://phabricator.services.mozilla.com/D235310
This commit is contained in:
Andreas Pehrson
2025-01-23 14:23:01 +00:00
parent 2b17464a67
commit 0da0d2d630

View File

@@ -109,6 +109,11 @@ bool ClearKeyUtils::DecryptCbcs(const vector<uint8_t>& aKey,
return false;
}
if (aSubsample.Length() == 0) {
// Nothing to decrypt.
return true;
}
std::unique_ptr<PK11SlotInfo, MaybeDeleteHelper<PK11SlotInfo>> slot(
PK11_GetInternalKeySlot());