提交 e8336229 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!92 fix codeDex warnings

Merge pull request !92 from 赵鹏元/master
...@@ -73,6 +73,7 @@ int TypeFactory::initFromFile(const std::string &filename) ...@@ -73,6 +73,7 @@ int TypeFactory::initFromFile(const std::string &filename)
name = normalizeTypeDeclaration(name); name = normalizeTypeDeclaration(name);
if (name.size() == 0) { if (name.size() == 0) {
fprintf(stderr, "Error: %d : missing type name\n", lc); fprintf(stderr, "Error: %d : missing type name\n", lc);
fclose(fp);
return -2; return -2;
} }
pos = last + 1; pos = last + 1;
...@@ -80,6 +81,7 @@ int TypeFactory::initFromFile(const std::string &filename) ...@@ -80,6 +81,7 @@ int TypeFactory::initFromFile(const std::string &filename)
size = getNextToken(str, pos, &last, WHITESPACE); size = getNextToken(str, pos, &last, WHITESPACE);
if (size.size() == 0) { if (size.size() == 0) {
fprintf(stderr, "Error: %d : missing type width\n", lc); fprintf(stderr, "Error: %d : missing type width\n", lc);
fclose(fp);
return -2; return -2;
} }
pos = last + 1; pos = last + 1;
...@@ -87,6 +89,7 @@ int TypeFactory::initFromFile(const std::string &filename) ...@@ -87,6 +89,7 @@ int TypeFactory::initFromFile(const std::string &filename)
printString = getNextToken(str, pos, &last, WHITESPACE); printString = getNextToken(str, pos, &last, WHITESPACE);
if (printString.size() == 0) { if (printString.size() == 0) {
fprintf(stderr, "Error: %d : missing print-string\n", lc); fprintf(stderr, "Error: %d : missing print-string\n", lc);
fclose(fp);
return -2; return -2;
} }
...@@ -103,15 +106,18 @@ int TypeFactory::initFromFile(const std::string &filename) ...@@ -103,15 +106,18 @@ int TypeFactory::initFromFile(const std::string &filename)
if (std::string("true")==pointerDef) { if (std::string("true")==pointerDef) {
if (!isPointer) { if (!isPointer) {
fprintf(stderr, "Error: %d: invalid isPointer definition: 'true' but name does not end with '*'!\n", lc); fprintf(stderr, "Error: %d: invalid isPointer definition: 'true' but name does not end with '*'!\n", lc);
fclose(fp);
return -2; return -2;
} }
} else if (std::string("false")==pointerDef) { } else if (std::string("false")==pointerDef) {
if (isPointer) { if (isPointer) {
fprintf(stderr, "Error: %d: invalid isPointer definition: 'false' but name does end with '*'!\n", lc); fprintf(stderr, "Error: %d: invalid isPointer definition: 'false' but name does end with '*'!\n", lc);
fclose(fp);
return -2; return -2;
} }
} else { } else {
fprintf(stderr, "Error: %d : invalid isPointer definition, must be either \"true\" or \"false\"\n", lc); fprintf(stderr, "Error: %d : invalid isPointer definition, must be either \"true\" or \"false\"\n", lc);
fclose(fp);
return -2; return -2;
} }
} }
...@@ -139,6 +145,7 @@ int TypeFactory::initFromFile(const std::string &filename) ...@@ -139,6 +145,7 @@ int TypeFactory::initFromFile(const std::string &filename)
isPointer))); //add a const type isPointer))); //add a const type
} }
g_initialized = true; g_initialized = true;
fclose(fp);
return 0; return 0;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "anbox/common/loop_device.h" #include "anbox/common/loop_device.h"
#include "anbox/defer_action.h" #include "anbox/defer_action.h"
#include <limits.h>
#include <system_error> #include <system_error>
#include <linux/loop.h> #include <linux/loop.h>
...@@ -50,7 +51,13 @@ bool LoopDevice::attach_file(const boost::filesystem::path &file_path) { ...@@ -50,7 +51,13 @@ bool LoopDevice::attach_file(const boost::filesystem::path &file_path) {
if (fd_ < 0) if (fd_ < 0)
return false; return false;
int file_fd = ::open(file_path.c_str(), O_RDONLY); const char* untrustPath = file_path.c_str();
char path[PATH_MAX] = {0};
if (realpath(untrustPath, path) == NULL) {
return false;
}
int file_fd = ::open(path, O_RDONLY);
if (file_fd < 0) if (file_fd < 0)
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册