Trim trailing zeros from build information.
[ Merge of http://go/wvgerrit/212252 ] 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:
@@ -2445,6 +2445,17 @@ bool CryptoSession::GetBuildInformation(RequestedSecurityLevel security_level,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
info->resize(info_length);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user