Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df9ea6e6 authored by Ravneet Dhanjal's avatar Ravneet Dhanjal
Browse files

Validate request metadata before coverting to camera metadata

- Backport similar fix from AIDL to HIDL to protect
from malformed metadata

Bug: 256166626
Test: CTS test
Change-Id: If8f83520144824e38ed102b7468d6d5ee2e6d963
parent afc2da8e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#define LOG_TAG "android.hardware.camera.device@3.2-convert-impl"
#include <log/log.h>
#include <system/camera_metadata.h>

#include "include/convert.h"

@@ -43,6 +44,13 @@ bool convertFromHidl(const CameraMetadata &src, const camera_metadata_t** dst) {
        ALOGE("%s: input CameraMetadata is corrupt!", __FUNCTION__);
        return false;
    }

    if (validate_camera_metadata_structure((camera_metadata_t*)data, /*expected_size=*/NULL) !=
        OK) {
        ALOGE("%s: Failed to validate the metadata structure", __FUNCTION__);
        return false;
    }

    *dst = (camera_metadata_t*) data;
    return true;
}