From b422cc3377f371206b3450f381523ab1201e38b1 Mon Sep 17 00:00:00 2001 From: wujianlin Date: Mon, 18 Nov 2024 19:29:01 +0800 Subject: [PATCH] Fully verify fileLength Issue:https://gitee.com/openharmony/commonlibrary_c_utils/issues/IB577P?from=project-issue Signed-off-by: wujianlin --- base/src/file_ex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/file_ex.cpp b/base/src/file_ex.cpp index 7ad317c..8238e80 100644 --- a/base/src/file_ex.cpp +++ b/base/src/file_ex.cpp @@ -117,7 +117,7 @@ bool LoadStringFromFile(const string& filePath, string& content) file.seekg(0, ios::end); const long long fileLength = file.tellg(); - if (fileLength > MAX_FILE_LENGTH) { + if (fileLength < 0 || fileLength > MAX_FILE_LENGTH) { UTILS_LOGD("invalid file length(%{public}lld)!", fileLength); return false; } -- Gitee