From cbb35277fa54694567eff89b312306bfce949b31 Mon Sep 17 00:00:00 2001 From: haixiangw Date: Mon, 18 Oct 2021 15:30:52 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20990f0b7=20from=20https://gitee.com/haix?= =?UTF-8?q?iangw/security=5Fhuks/pulls/108=20=E6=96=87=E4=BB=B6=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=A2=9E=E5=8A=A0fsync?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: haixiangw --- .../main/os_dependency/posix/hks_file_operator_lite.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/huks_standard/huks_service/main/os_dependency/posix/hks_file_operator_lite.c b/services/huks_standard/huks_service/main/os_dependency/posix/hks_file_operator_lite.c index be430ecc3..f4a7dd86a 100644 --- a/services/huks_standard/huks_service/main/os_dependency/posix/hks_file_operator_lite.c +++ b/services/huks_standard/huks_service/main/os_dependency/posix/hks_file_operator_lite.c @@ -145,12 +145,13 @@ static int32_t FileWrite(const char *fileName, uint32_t offset, const uint8_t *b } int32_t size = write(fd, buf, len); - close(fd); if (size < 0) { HKS_LOG_E("write file size failed, errno = 0x%x", errno); + close(fd); return HKS_ERROR_WRITE_FILE_FAIL; } - + fsync(fd); + close(fd); return HKS_SUCCESS; } -- Gitee