Piglit would segfault if piglit_load_text_file() was accidentally passed
a directory name instead of a filename.  Now return NULL if the file is
not regular or a symlink.
---
 tests/util/piglit-util.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index f6c2ba0..888b8b8 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -304,6 +304,13 @@ char *piglit_load_text_file(const char *file_name, 
unsigned *size)
        if (fstat(fd, & st) == 0) {
                ssize_t total_read = 0;
 
+                if (!S_ISREG(st.st_mode) &&
+                    !S_ISLNK(st.st_mode)) {
+                   /* not a regular file or symlink */
+                   close(fd);
+                   return NULL;
+                }
+
                text = malloc(st.st_size + 1);
                if (text != NULL) {
                        do {
-- 
1.7.7.3

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to