Mesa (10.4): r300g: Check return value of snprintf().
Emil Velikov
evelikov at kemper.freedesktop.org
Sat Mar 7 16:52:54 UTC 2015
Module: Mesa
Branch: 10.4
Commit: 93273f16afd4be9bf4ff364a21217994837b28bb
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=93273f16afd4be9bf4ff364a21217994837b28bb
Author: Matt Turner <mattst88 at gmail.com>
Date: Tue Mar 3 16:09:58 2015 -0800
r300g: Check return value of snprintf().
Would have at least prevented the crash the previous patch fixed.
Cc: 10.4, 10.5 <mesa-stable at lists.freedesktop.org>
Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970
Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
(cherry picked from commit ade0b580e75bdea227eec5345f6681b678d0811b)
---
src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
index 422bdb0..04c01f1 100644
--- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
+++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c
@@ -541,9 +541,14 @@ unsigned load_program(
unsigned *count;
char **string_store;
unsigned i = 0;
+ int n;
memset(line, 0, sizeof(line));
- snprintf(path, PATH_MAX, TEST_PATH "/%s", filename);
+ n = snprintf(path, PATH_MAX, TEST_PATH "/%s", filename);
+ if (n < 0 || n >= PATH_MAX) {
+ return 0;
+ }
+
file = fopen(path, "r");
if (!file) {
return 0;
More information about the mesa-commit
mailing list