From 033e78e80ce2d6feb2aaabbe389127b16c51d15c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Mon, 10 Sep 2018 13:21:19 +0900 Subject: [PATCH] Set umask for temp file generation (#2637) Set umask and recover after generate temporary file to avoid security issue Signed-off-by: Hyeongseok Oh --- runtimes/tests/neural_networks_test/TestValidation.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runtimes/tests/neural_networks_test/TestValidation.cpp b/runtimes/tests/neural_networks_test/TestValidation.cpp index 3061f96..e4f287a 100644 --- a/runtimes/tests/neural_networks_test/TestValidation.cpp +++ b/runtimes/tests/neural_networks_test/TestValidation.cpp @@ -33,7 +33,12 @@ static int shmem_create_region(size_t size) { char temp[PATH_MAX]; snprintf(temp, sizeof(temp), "/tmp/nn-shmem-%d-%d-XXXXXXXXX", getpid(), shmem_num++); + + // Set umask and recover after generate temporary file to avoid security issue + mode_t umaskPrev = umask(S_IRUSR|S_IWUSR); int fd = mkstemp(temp); + umask(umaskPrev); + if (fd == -1) return -1; unlink(temp); -- 2.7.4