summaryrefslogtreecommitdiff
path: root/include/android/hardware/libhardware
diff options
context:
space:
mode:
authorHirokazu Honda <hiroh@chromium.org>2021-04-03 22:37:41 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-04-04 01:47:32 +0300
commit90a0430abcfcd578659c184ae293b8af753f9182 (patch)
tree17cc4c86c6566975ac731531e454660c28c2d95c /include/android/hardware/libhardware
parent7633a2d24d86554ef3586a7adad02f81555f4440 (diff)
android: CameraDevice: Add more camera3_capture_request validation
This adds more validation to camera3_capture_request mainly about buffer_handle values. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'include/android/hardware/libhardware')
0 files changed, 0 insertions, 0 deletions
href='#n124'>124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
{#-
 # SPDX-License-Identifier: LGPL-2.1-or-later
 # Copyright (C) 2020, Google Inc.
-#}
{#
 # \brief Generate function prototype
 #
 # \param class Class name
 # \param method mojom Method object
 # \param suffix Suffix to append to \a method function name
 # \param need_class_name If true, generate class name with function
 # \param override If true, generate override tag after the function prototype
 #}
{%- macro func_sig(class, method, suffix = "", need_class_name = true, override = false) -%}
{{method|method_return_value}} {{class + "::" if need_class_name}}{{method.mojom_name}}{{suffix}}(
{%- for param in method|method_parameters %}
	{{param}}{{- "," if not loop.last}}
{%- endfor -%}
){{" override" if override}}
{%- endmacro -%}

{#
 # \brief Generate function body for IPA stop() function for thread
 #}
{%- macro stop_thread_body() -%}
	ASSERT(state_ != ProxyStopping);
	if (state_ != ProxyRunning)
		return;

	state_ = ProxyStopping;

	proxy_.invokeMethod(&ThreadProxy::stop, ConnectionTypeBlocking);

	thread_.exit();
	thread_.wait();

	Thread::current()->dispatchMessages(Message::Type::InvokeMessage);

	state_ = ProxyStopped;
{%- endmacro -%}


{#
 # \brief Serialize multiple objects into data buffer and fd vector
 #
 # Generate code to serialize multiple objects, as specified in \a params
 # (which are the parameters to some function), into \a buf data buffer and
 # \a fds fd vector.
 # This code is meant to be used by the proxy, for serializing prior to IPC calls.
 #
 # \todo Avoid intermediate vectors
 #}
{%- macro serialize_call(params, buf, fds) %}
{%- for param in params %}
	std::vector<uint8_t> {{param.mojom_name}}Buf;
{%- if param|has_fd %}
	std::vector<SharedFD> {{param.mojom_name}}Fds;
	std::tie({{param.mojom_name}}Buf, {{param.mojom_name}}Fds) =
{%- else %}
	std::tie({{param.mojom_name}}Buf, std::ignore) =
{%- endif %}
		IPADataSerializer<{{param|name}}>::serialize({{param.mojom_name}}
{{- ", &controlSerializer_" if param|needs_control_serializer -}}
);
{%- endfor %}

{%- if params|length > 1 %}
{%- for param in params %}
	appendPOD<uint32_t>({{buf}}, {{param.mojom_name}}Buf.size());
{%- if param|has_fd %}
	appendPOD<uint32_t>({{buf}}, {{param.mojom_name}}Fds.size());
{%- endif %}
{%- endfor %}
{%- endif %}

{%- for param in params %}
	{{buf}}.insert({{buf}}.end(), {{param.mojom_name}}Buf.begin(), {{param.mojom_name}}Buf.end());
{%- endfor %}

{%- for param in params %}
{%- if param|has_fd %}
	{{fds}}.insert({{fds}}.end(), {{param.mojom_name}}Fds.begin(), {{param.mojom_name}}Fds.end());
{%- endif %}
{%- endfor %}
{%- endmacro -%}


{#
 # \brief Deserialize a single object from data buffer and fd vector
 #
 # \param pointer If true, deserialize the object into a dereferenced pointer
 # \param iter If true, treat \a buf as an iterator instead of a vector
 # \param data_size Variable that holds the size of the vector referenced by \a buf
 #
 # Generate code to deserialize a single object, as specified in \a param,
 # from \a buf data buffer and \a fds fd vector.
 # This code is meant to be used by macro deserialize_call.
 #}
{%- macro deserialize_param(param, pointer, loop, buf, fds, iter, data_size) -%}
{{"*" if pointer}}{{param.mojom_name}} = IPADataSerializer<{{param|name}}>::deserialize(
	{{buf}}{{- ".cbegin()" if not iter}} + {{param.mojom_name}}Start,
{%- if loop.last and not iter %}
	{{buf}}.cend()
{%- elif not iter %}
	{{buf}}.cbegin() + {{param.mojom_name}}Start + {{param.mojom_name}}BufSize
{%- elif iter and loop.length == 1 %}
	{{buf}} + {{data_size}}
{%- else %}
	{{buf}} + {{param.mojom_name}}Start + {{param.mojom_name}}BufSize
{%- endif -%}
{{- "," if param|has_fd}}
{%- if param|has_fd %}
	{{fds}}.cbegin() + {{param.mojom_name}}FdStart,
{%- if loop.last %}
	{{fds}}.cend()
{%- else %}
	{{fds}}.cbegin() + {{param.mojom_name}}FdStart + {{param.mojom_name}}FdsSize
{%- endif -%}
{%- endif -%}
{{- "," if param|needs_control_serializer}}
{%- if param|needs_control_serializer %}
	&controlSerializer_
{%- endif -%}
);
{%- endmacro -%}


{#
 # \brief Deserialize multiple objects from data buffer and fd vector
 #
 # \param pointer If true, deserialize objects into pointers, and adds a null check.
 # \param declare If true, declare the objects in addition to deserialization.
 # \param iter if true, treat \a buf as an iterator instead of a vector
 # \param data_size Variable that holds the size of the vector referenced by \a buf
 #
 # Generate code to deserialize multiple objects, as specified in \a params
 # (which are the parameters to some function), from \a buf data buffer and
 # \a fds fd vector.
 # This code is meant to be used by the proxy, for deserializing after IPC calls.
 #
 # \todo Avoid intermediate vectors
 #}
{%- macro deserialize_call(params, buf, fds, pointer = true, declare = false, iter = false, data_size = '', init_offset = 0) -%}
{% set ns = namespace(size_offset = init_offset) %}
{%- if params|length > 1 %}
{%- for param in params %}
	[[maybe_unused]] const size_t {{param.mojom_name}}BufSize = readPOD<uint32_t>({{buf}}, {{ns.size_offset}}
{%- if iter -%}
, {{buf}} + {{data_size}}
{%- endif -%}
);
	{%- set ns.size_offset = ns.size_offset + 4 %}
{%- if param|has_fd %}
	[[maybe_unused]] const size_t {{param.mojom_name}}FdsSize = readPOD<uint32_t>({{buf}}, {{ns.size_offset}}
{%- if iter -%}
, {{buf}} + {{data_size}}
{%- endif -%}
);
	{%- set ns.size_offset = ns.size_offset + 4 %}
{%- endif %}
{%- endfor %}
{%- endif %}
{% for param in params %}
{%- if loop.first %}
	const size_t {{param.mojom_name}}Start = {{ns.size_offset}};
{%- else %}
	const size_t {{param.mojom_name}}Start = {{loop.previtem.mojom_name}}Start + {{loop.previtem.mojom_name}}BufSize;
{%- endif %}
{%- endfor %}
{% for param in params|with_fds %}
{%- if loop.first %}
	const size_t {{param.mojom_name}}FdStart = 0;
{%- elif not loop.last %}
	const size_t {{param.mojom_name}}FdStart = {{loop.previtem.mojom_name}}FdStart + {{loop.previtem.mojom_name}}FdsSize;
{%- endif %}
{%- endfor %}
{% for param in params %}
	{%- if pointer %}
	if ({{param.mojom_name}}) {
{{deserialize_param(param, pointer, loop, buf, fds, iter, data_size)|indent(16, True)}}
	}
	{%- else %}
	{{param|name + " " if declare}}{{deserialize_param(param, pointer, loop, buf, fds, iter, data_size)|indent(8)}}
	{%- endif %}
{% endfor %}
{%- endmacro -%}