[Piglit] [PATCH] Fix out of bounds read in the AMD_performance_monitor measure test.

Kenneth Graunke kenneth at whitecape.org
Thu Sep 19 15:41:48 PDT 2013


If the last counter returned is a 32-bit value, reading a uint64_t might
go past the end of the buffer.  So, delay reading the 64-bit value until
we know the type is 64-bit.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 tests/spec/amd_performance_monitor/measure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/spec/amd_performance_monitor/measure.c b/tests/spec/amd_performance_monitor/measure.c
index bc39c84..61c98b1 100644
--- a/tests/spec/amd_performance_monitor/measure.c
+++ b/tests/spec/amd_performance_monitor/measure.c
@@ -194,7 +194,6 @@ test_basic_measurement(unsigned group)
 		/* Counter values */
 		uint32_t u32 = p[2];
 		float f = ((float *) p)[2];
-		uint64_t u64 = ((uint64_t *) p)[1];
 
 		/* Query results */
 		GLenum counter_type = GL_NONE;
@@ -226,6 +225,7 @@ test_basic_measurement(unsigned group)
 			break;
 		}
 		case GL_UNSIGNED_INT64_AMD: {
+			uint64_t u64 = ((uint64_t *) p)[1];
 			verify(u64 >= range[0]);
 			verify(u64 <= range[1]);
 			break;
-- 
1.8.3.4



More information about the Piglit mailing list