From 8fd54c107a01f98cf9c731104b0d3eaa2b85bfa4 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 13 May 2014 11:39:30 +0200 Subject: Related fdo#60338: Do not use umask(3) in a MT program Change-Id: Ie515201e44ad58faf623a04981e891c0b3f4a19d --- shell/source/unix/sysshell/recently_used_file.cxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'shell') diff --git a/shell/source/unix/sysshell/recently_used_file.cxx b/shell/source/unix/sysshell/recently_used_file.cxx index 2bce26c8b972..2189d0bce12e 100644 --- a/shell/source/unix/sysshell/recently_used_file.cxx +++ b/shell/source/unix/sysshell/recently_used_file.cxx @@ -63,13 +63,12 @@ recently_used_file::recently_used_file() : OString tmp = OUStringToOString(rufn, osl_getThreadTextEncoding()); - file_ = fopen(tmp.getStr(), "r+"); - - /* create if not exist */ - if (NULL == file_) { - mode_t umask_ = umask(S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); - file_ = fopen(tmp.getStr(), "w+"); - umask(umask_); + int fd = open(tmp.getStr(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + if (fd != -1) { + file_ = fdopen(fd, "w+"); + if (file_ == 0) { + close(fd); + } } if (NULL == file_) -- cgit