From dbdbcaf16a9c5bc1e6eae917d92fe4e6031a0ab4 Mon Sep 17 00:00:00 2001 From: David Stevens Date: Thu, 4 Oct 2018 17:03:21 -0700 Subject: [PATCH] [display] Validate pixel formats Bug: ZX-2329 Test: Locally modify virtcon to pass wrong display format Change-Id: I7812dd82803a5b362626ba1bd681a080d1d68ad7 --- system/dev/display/display/client.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/system/dev/display/display/client.cpp b/system/dev/display/display/client.cpp index 7e9ed3bd0d..920873dbe7 100644 --- a/system/dev/display/display/client.cpp +++ b/system/dev/display/display/client.cpp @@ -924,9 +924,25 @@ bool Client::CheckConfig(fidl::Builder* resp_builder) { }; invalid = (!frame_contains(image_frame, layer->src_frame) || !frame_contains(display_frame, layer->dest_frame)); + + if (!invalid) { + invalid = true; + for (auto fmt : display_config.pixel_formats_) { + if (fmt == layer->image.pixel_format) { + invalid = false; + break; + } + } + } } else if (layer_node.layer->pending_layer_.type == LAYER_CURSOR) { - // The image is already set, so nothing to do here, and there's - // nothing that could make this invald. + invalid = true; + auto& cursor_cfg = layer_node.layer->pending_layer_.cfg.cursor; + for (auto& cursor_info : display_config.cursor_infos_) { + if (cursor_info.format == cursor_cfg.image.pixel_format) { + invalid = false; + break; + } + } } else if (layer_node.layer->pending_layer_.type == LAYER_COLOR) { // There aren't any API constraints on valid colors. layer_node.layer->pending_layer_.cfg.color.color =