!135 修复沙箱路径规范化的问题

Merge pull request !135 from 蒋为正/master
This commit is contained in:
openharmony_ci 2022-09-20 13:00:34 +00:00 committed by Gitee
commit cda897fb8a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -56,7 +56,9 @@ std::string CanonicalizeSpecPath(const char* src)
}
#else
if (access(src, F_OK) == 0) {
if (realpath(src, resolvedPath) == nullptr) {
if (strstr(src, "/proc/") == src && strstr(src, "/data/storage") != nullptr) { // for sandbox
(void)strncpy_s(resolvedPath, sizeof(resolvedPath), src, strlen(src));
} else if (realpath(src, resolvedPath) == nullptr) {
fprintf(stderr, "Error: realpath %s failed", src);
return "";
}