!107 添加路径校验

Merge pull request !107 from f房芷仪/1028
This commit is contained in:
openharmony_ci 2024-10-31 04:19:19 +00:00 committed by Gitee
commit 102c7c5dd9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -3,7 +3,7 @@ new file mode 100644
index 00000000..422e0d52
--- /dev/null
+++ b/contrib/android/dac_config.cpp
@@ -0,0 +1,240 @@
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
+ * This program is free software; you can redistribute it and/or modify
@ -29,6 +29,7 @@ index 00000000..422e0d52
+#include <unordered_map>
+#include <vector>
+#include <linux/capability.h>
+#include <limits.h>
+
+using namespace std;
+
@ -154,7 +155,12 @@ index 00000000..422e0d52
+extern "C" {
+ int LoadDacConfig(const char* fn)
+ {
+ ifstream readFile(fn);
+ char resolvedPath[PATH_MAX] = {'\0'};
+ char *canonicalPath = realpath(fn, resolvedPath);
+ if (canonicalPath == nullptr) {
+ return -1;
+ }
+ ifstream readFile(canonicalPath);
+ if (readFile.fail()) {
+ return -1;
+ }