From 45a6880d789414b85028c8e7b56f920f162d2d04 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 16 Oct 2018 09:16:36 +0000 Subject: [PATCH] unit_tests: call umask before mkstemp Coverity 188788 --- tests/unit_tests/notify.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit_tests/notify.cpp b/tests/unit_tests/notify.cpp index d6811c6bd..e2477a76e 100644 --- a/tests/unit_tests/notify.cpp +++ b/tests/unit_tests/notify.cpp @@ -26,6 +26,10 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#ifdef __GLIBC__ +#include +#endif + #include "gtest/gtest.h" #include @@ -37,8 +41,14 @@ TEST(notify, works) { +#ifdef __GLIBC__ + mode_t prevmode = umask(077); +#endif char name_template[] = "/tmp/monero-notify-unit-test-XXXXXX"; int fd = mkstemp(name_template); +#ifdef __GLIBC__ + umask(prevmode); +#endif ASSERT_TRUE(fd >= 0); close(fd);