From 18dcbadf2771cdb0c18509b14e4e73505b242753 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Sun, 21 Jan 2018 01:29:10 +0900 Subject: Make temporary directory safely when ~/.w3m is unwritable --- rc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'rc.c') diff --git a/rc.c b/rc.c index eb562c9..3fd84ef 100644 --- a/rc.c +++ b/rc.c @@ -1330,6 +1330,11 @@ init_rc(void) ((tmp_dir = getenv("TMP")) == NULL || *tmp_dir == '\0') && ((tmp_dir = getenv("TEMP")) == NULL || *tmp_dir == '\0')) tmp_dir = "/tmp"; +#ifdef HAVE_MKDTEMP + tmp_dir = mkdtemp(Strnew_m_charp(tmp_dir, "/w3m-XXXXXX", NULL)->ptr); + if (tmp_dir == NULL) + tmp_dir = rc_dir; +#endif create_option_search_table(); goto open_rc; } -- cgit v1.2.3