Commit 90a0430a authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Laurent Pinchart
Browse files

android: CameraDevice: Add more camera3_capture_request validation



This adds more validation to camera3_capture_request mainly
about buffer_handle values.
Signed-off-by: default avatarHirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
parent 7633a2d2
......@@ -263,11 +263,38 @@ bool isValidRequest(camera3_capture_request_t *camera3Request)
return false;
}
if (!camera3Request->num_output_buffers) {
if (!camera3Request->num_output_buffers ||
!camera3Request->output_buffers) {
LOG(HAL, Error) << "No output buffers provided";
return false;
}
for (uint32_t i = 0; i < camera3Request->num_output_buffers; i++) {
const camera3_stream_buffer_t &outputBuffer =
camera3Request->output_buffers[i];
if (!outputBuffer.buffer || !(*outputBuffer.buffer)) {
LOG(HAL, Error) << "Invalid native handle";
return false;
}
const native_handle_t *handle = *outputBuffer.buffer;
constexpr int kNativeHandleMaxFds = 1024;
if (handle->numFds < 0 || handle->numFds > kNativeHandleMaxFds) {
LOG(HAL, Error)
<< "Invalid number of fds (" << handle->numFds
<< ") in buffer " << i;
return false;
}
constexpr int kNativeHandleMaxInts = 1024;
if (handle->numInts < 0 || handle->numInts > kNativeHandleMaxInts) {
LOG(HAL, Error)
<< "Invalid number of ints (" << handle->numInts
<< ") in buffer " << i;
return false;
}
}
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment