gatekeeperd: protect from invalid data passed by HAL

am: 8c63536ded

Change-Id: Ie020281e63504ea0b9f27e9e36433d3e137ae018
This commit is contained in:
Alexey Polyudov 2017-01-04 03:31:20 +00:00 committed by android-build-merger
commit 563ed1672f
1 changed files with 8 additions and 1 deletions

View File

@ -166,7 +166,14 @@ public:
enrolled_password_handle, enrolled_password_handle_length);
}
if (ret == 0) {
if (ret == GATEKEEPER_RESPONSE_OK && (*enrolled_password_handle == nullptr ||
*enrolled_password_handle_length != sizeof(password_handle_t))) {
ret = GATEKEEPER_RESPONSE_ERROR;
ALOGE("HAL: password_handle=%p size_of_handle=%" PRIu32 "\n",
*enrolled_password_handle, *enrolled_password_handle_length);
}
if (ret == GATEKEEPER_RESPONSE_OK) {
gatekeeper::password_handle_t *handle =
reinterpret_cast<gatekeeper::password_handle_t *>(*enrolled_password_handle);
store_sid(uid, handle->user_id);