r300g: Check return value of snprintf().
authorMatt Turner <mattst88@gmail.com>
Wed, 4 Mar 2015 00:09:58 +0000 (16:09 -0800)
committerMatt Turner <mattst88@gmail.com>
Wed, 4 Mar 2015 19:15:09 +0000 (11:15 -0800)
Would have at least prevented the crash the previous patch fixed.

Cc: 10.4, 10.5 <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=540970
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c

index 422bdb04405bb0f0dd5f3b6eee4fb9cfd310e62b..04c01f1b44316d0b0f2e3d61dc00c94f167e2b3e 100644 (file)
@@ -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;