NULL terminate device unique ID before use

bug: 12228689

If the device ID returned from OEMCrypto_GetDeviceUniqueId is
not NULL terminated in the OEM code, trailing garbage characters
may be included in the license request's client_identification
field, which could be rejected by the server's utf8 parser if
they are invalid characters, causing a license request failure.

The code for CryptoSession::GetDeviceUniqueId should use the
updated id_length from OEMCrypto_GetDeviceUniqueId to adjust
the length of the *device_id string before returning the result
to the caller.

Change-Id: I659866d4234d4f21ec051590fc7bc6367904a48a
This commit is contained in:
Jeff Tinker
2013-12-19 16:05:06 -08:00
parent 78a9d5cd9a
commit 1c5ca642cb

View File

@@ -155,6 +155,9 @@ bool CryptoSession::GetDeviceUniqueId(std::string* device_id) {
return false;
}
id.resize(id_length + 1);
id[id_length] = '\0';
*device_id = reinterpret_cast<const char*>(&id[0]);
return true;
}