From 48b16e2725249985c9f1841928eb08574c24d3cc Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 14 Apr 2014 08:23:23 -0600 Subject: [PATCH] stat: check that TEMP environment variable is half-way sane Signed-off-by: Jens Axboe --- stat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stat.c b/stat.c index 509c6f02..5a553d00 100644 --- a/stat.c +++ b/stat.c @@ -1494,8 +1494,11 @@ static int check_status_file(void) return 0; temp_dir = getenv("TMPDIR"); - if (temp_dir == NULL) + if (temp_dir == NULL) { temp_dir = getenv("TEMP"); + if (temp_dir && strlen(temp_dir) >= PATH_MAX) + temp_dir = NULL; + } if (temp_dir == NULL) temp_dir = "/tmp"; -- 2.25.1