!7796 [Bug]: fix warning of security

Merge pull request !7796 from yangxiaoshuai2022/warning_fix_0614
This commit is contained in:
openharmony_ci 2024-06-14 09:29:20 +00:00 committed by Gitee
commit dce94cf201
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 12 additions and 4 deletions

View File

@ -13,6 +13,7 @@
* limitations under the License.
*/
#include "ecmascript/compiler/aot_file/elf_checker.h"
#include "ecmascript/platform/file.h"
#include <fstream>
#include <type_traits>
@ -88,6 +89,9 @@ ElfChecker::ElfChecker(const void* data, int len) : elfLen_(len), elfErrorCode_(
ElfChecker::ElfChecker(const std::string& path) : elfErrorCode_(0), fromMmap_(false)
{
if (!panda::ecmascript::FileExist(path.c_str())) {
return;
}
std::ifstream file(path, std::ios::binary | std::ios::ate);
if (file.is_open() == false) {
elfData_ = nullptr;

View File

@ -20,6 +20,7 @@
#include "constants.h"
#include "file_path_utils.h"
#include "securec.h"
#include "ecmascript/platform/file.h"
namespace panda {
namespace ecmascript {
@ -110,6 +111,9 @@ bool Extractor::ExtractByName(const std::string &fileName, std::ostream &dest) c
bool Extractor::ExtractFile(const std::string &fileName, const std::string &targetPath) const
{
if (!panda::ecmascript::FileExist(targetPath.c_str())) {
return false;
}
std::ofstream fileStream;
fileStream.open(targetPath, std::ios_base::out | std::ios_base::binary);
if (!fileStream.is_open()) {

View File

@ -114,7 +114,7 @@ EcmaRuntimeCallInfo* EcmaInterpreter::ReBuildRuntimeCallInfo(JSThread *thread, E
*(--currentSp) = thisObj.GetRawData();
*(--currentSp) = newTarget.GetRawData();
*(--currentSp) = func.GetRawData();
*(--currentSp) = numArgs + NUM_MANDATORY_JSFUNC_ARGS;
*(--currentSp) = numArgs + static_cast<int>(NUM_MANDATORY_JSFUNC_ARGS);
*(--currentSp) = ToUintPtr(thread);
EcmaRuntimeCallInfo *ecmaRuntimeCallInfo = reinterpret_cast<EcmaRuntimeCallInfo *>(currentSp);

View File

@ -148,4 +148,4 @@ class XScroll {
module.exports = {
XScroll
}
};

View File

@ -917,7 +917,7 @@ class IrViewer {
}
}
}, this.findNext.bind(this));
}
};
CanvasInput.SetSafeArea(...this.searchInput.pos);
this.searchInput.Open();
}

View File

@ -23,4 +23,4 @@ module.exports = {
path: path.join(__dirname, 'dist'),
filename: 'main.js'
}
}
};