diff options
| author | Courtney Goeltzenleuchter <courtneygo@google.com> | 2016-12-21 16:24:34 -0700 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtneygo@google.com> | 2016-12-21 16:35:36 -0700 |
| commit | 00a87deb5fc33be4512b71725d2593555de79171 (patch) | |
| tree | 07e400adc941d117641c3f71706b361a5e98696f /layers | |
| parent | bee1d3a4e8c0d48dc5f77c26963e792f4c3b306c (diff) | |
| download | usermoji-00a87deb5fc33be4512b71725d2593555de79171.tar.xz | |
loader: Fix validation error
The string length validation will not detect strings
that exceed the max length.
For example, when i = max_length-1 and utf8[i] is a valid
character (>= 0x20 and < 0x7f) no error is thrown and
the next iteration will end the loop.
This change extends the loop and the if check to
catch this issue.
Diffstat (limited to 'layers')
| -rw-r--r-- | layers/vk_layer_utils.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/layers/vk_layer_utils.cpp b/layers/vk_layer_utils.cpp index 4ad1989b..8d912d71 100644 --- a/layers/vk_layer_utils.cpp +++ b/layers/vk_layer_utils.cpp @@ -695,9 +695,12 @@ VK_LAYER_EXPORT VkStringErrorFlags vk_string_validate(const int max_length, cons int num_char_bytes = 0; int i, j; - for (i = 0; i < max_length; i++) { + for (i = 0; i <= max_length; i++) { if (utf8[i] == 0) { break; + } else if (i == max_length) { + result = VK_STRING_ERROR_LENGTH; + break; } else if ((utf8[i] >= 0xa) && (utf8[i] < 0x7f)) { num_char_bytes = 0; } else if ((utf8[i] & UTF8_ONE_BYTE_MASK) == UTF8_ONE_BYTE_CODE) { |
