aboutsummaryrefslogtreecommitdiff
path: root/layers/parameter_validation.cpp
diff options
context:
space:
mode:
authorMike Weiblen <mikew@lunarg.com>2016-10-31 11:05:56 -0600
committerMike Weiblen <mikew@lunarg.com>2016-11-02 12:46:04 -0600
commit70de400fdbd60f753d48590ed8241edbab460f56 (patch)
tree54c1827861a177c049b1a66a781c418294c439dc /layers/parameter_validation.cpp
parentc1b3bd05f0681485fb7a66b6e4372dc472217f48 (diff)
downloadusermoji-70de400fdbd60f753d48590ed8241edbab460f56.tar.xz
layers: GH934 Bounds checking on SetScissor
Change-Id: I3b14cc79f851eb66401da659cb0dade9888d84a8
Diffstat (limited to 'layers/parameter_validation.cpp')
-rw-r--r--layers/parameter_validation.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp
index 4064e6fd..0cc31a11 100644
--- a/layers/parameter_validation.cpp
+++ b/layers/parameter_validation.cpp
@@ -23,6 +23,7 @@
#define NOMINMAX
+#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -3992,9 +3993,36 @@ VKAPI_ATTR void VKAPI_CALL CmdSetScissor(VkCommandBuffer commandBuffer, uint32_t
bool skip_call = false;
layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map);
assert(my_data != NULL);
+ debug_report_data *report_data = my_data->report_data;
skip_call |= parameter_validation_vkCmdSetScissor(my_data->report_data, firstScissor, scissorCount, pScissors);
+ for (uint32_t scissorIndex = 0; scissorIndex < scissorCount; ++scissorIndex) {
+ const VkRect2D &pScissor = pScissors[scissorIndex];
+
+ if (pScissor.offset.x < 0) {
+ skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_01489, LayerName, "vkCmdSetScissor %d: offset.x (%d) must not be negative. %s",
+ scissorIndex, pScissor.offset.x, validation_error_map[VALIDATION_ERROR_01489]);
+ } else if (static_cast<int32_t>(pScissor.extent.width) > (INT_MAX - pScissor.offset.x)) {
+ skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_01490, LayerName,
+ "vkCmdSetScissor %d: adding offset.x (%d) and extent.width (%u) will overflow. %s", scissorIndex,
+ pScissor.offset.x, pScissor.extent.width, validation_error_map[VALIDATION_ERROR_01490]);
+ }
+
+ if (pScissor.offset.y < 0) {
+ skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_01489, LayerName, "vkCmdSetScissor %d: offset.y (%d) must not be negative. %s",
+ scissorIndex, pScissor.offset.y, validation_error_map[VALIDATION_ERROR_01489]);
+ } else if (static_cast<int32_t>(pScissor.extent.height) > (INT_MAX - pScissor.offset.y)) {
+ skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_01491, LayerName,
+ "vkCmdSetScissor %d: adding offset.y (%d) and extent.height (%u) will overflow. %s", scissorIndex,
+ pScissor.offset.y, pScissor.extent.height, validation_error_map[VALIDATION_ERROR_01491]);
+ }
+ }
+
if (!skip_call) {
get_dispatch_table(pc_device_table_map, commandBuffer)->CmdSetScissor(commandBuffer, firstScissor, scissorCount, pScissors);
}