glsl: fix heap-buffer-overflow
authorBartosz Tomczyk <bartosz.tomczyk86@gmail.com>
Tue, 31 Jan 2017 11:02:20 +0000 (12:02 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 31 Jan 2017 14:58:52 +0000 (15:58 +0100)
The `end+1` skips the ']', whereas the `strlen+1` includes the final
'\0' in the move to terminate the string.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/compiler/glsl/link_uniforms.cpp

index 8930d26a5ca2812e588fd420d1c8357b9c746fe3..e9a20530b57bace3e227248c53ed163733e18c4c 100644 (file)
@@ -535,7 +535,7 @@ private:
             const char *str_end;
             while((str_start = strchr(name_copy, '[')) &&
                   (str_end = strchr(name_copy, ']'))) {
-               memmove(str_start, str_end + 1, 1 + strlen(str_end));
+               memmove(str_start, str_end + 1, 1 + strlen(str_end + 1));
             }
 
             unsigned index = 0;