Trim trailing zeros from build information.

[ Cherry-pick of http://go/wvgerrit/212250 ]

Certain OEMCrypto implementations are returning build info with
trailing C-string null bytes; others are returning all null bytes.

This change attempts to trim any trailing zeros.  For build info
with a single trailing zero, this should fix the format; for those
containing all zeros, this will indicate a failure on OEMCrypto's part
for returning all zeros.  The CDM will not prevent request generation,
but will omit the result in the ClientIdentification.  The server
will decide whether to provide a response or not.

Bug: 348497732
Bug: 348498112
Bug: 366819137
Change-Id: I281ab14e0e46116825321a7965d971b9d68c49fc
(cherry picked from commit 7c81f7bed4fec8199f7fbdb5e95452eacdf3b3c7)
This commit is contained in:
Alex Dale
2024-08-09 21:45:58 -07:00
parent ae80e87d0e
commit 04a70543ea

View File

@@ -2541,6 +2541,17 @@ bool CryptoSession::GetBuildInformation(RequestedSecurityLevel security_level,
return false;
}
info->resize(info_length);
// Some OEMCrypto implementations may include trailing null
// bytes in the output. Trim them here.
while (!info->empty() && info->back() == '\0') {
info->pop_back();
}
if (info->empty()) {
LOGE("BuildInformation() returned corrupted data: length = %zu",
info_length);
return false;
}
return true;
}