stat: check that TEMP environment variable is half-way sane
authorJens Axboe <axboe@fb.com>
Mon, 14 Apr 2014 14:23:23 +0000 (08:23 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 14 Apr 2014 14:23:23 +0000 (08:23 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
stat.c

diff --git a/stat.c b/stat.c
index 509c6f02875aee1c648f9e9a432b108a6aa768c8..5a553d00653700634872e406b6b280bb3c02d763 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1494,8 +1494,11 @@ static int check_status_file(void)
                return 0;
 
        temp_dir = getenv("TMPDIR");
                return 0;
 
        temp_dir = getenv("TMPDIR");
-       if (temp_dir == NULL)
+       if (temp_dir == NULL) {
                temp_dir = getenv("TEMP");
                temp_dir = getenv("TEMP");
+               if (temp_dir && strlen(temp_dir) >= PATH_MAX)
+                       temp_dir = NULL;
+       }
        if (temp_dir == NULL)
                temp_dir = "/tmp";
 
        if (temp_dir == NULL)
                temp_dir = "/tmp";