!138 codedex问题

Merge pull request !138 from xiangjiaming/master
This commit is contained in:
openharmony_ci 2022-02-22 12:41:54 +00:00 committed by Gitee
commit 81e8356d58
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 17 additions and 6 deletions

View File

@ -23,12 +23,18 @@
#include <poll.h>
#include <sys/stat.h>
#include <unistd.h>
#include <climits>
FTRACE_NS_BEGIN
FtraceDataReader::FtraceDataReader(const std::string& path) : path_(path), readFd_(-1)
{
readFd_ = open(path.c_str(), O_CLOEXEC | O_NONBLOCK);
CHECK_TRUE(readFd_ >= 0, NO_RETVAL, "open %s failed, %d", path_.c_str(), errno);
char realPath[PATH_MAX + 1] = {0};
if ((path.length() > PATH_MAX) || (realpath(path.c_str(), realPath) == nullptr)) {
HILOG_ERROR(LOG_CORE, "%s:so filename invalid, errno=%d", __func__, errno);
}
readFd_ = open(realPath, O_CLOEXEC | O_NONBLOCK);
CHECK_TRUE(readFd_ >= 0, NO_RETVAL, "open %s failed, %d", realPath, errno);
}
FtraceDataReader::~FtraceDataReader()

View File

@ -28,16 +28,20 @@ FileCache::~FileCache()
bool FileCache::Open(const std::string& file)
{
if (path_.length() > PATH_MAX) {
std::string path = path_ + file;
char realPath[PATH_MAX + 1] = {0};
if ((path.length() > PATH_MAX) || (realpath(path.c_str(), realPath) == nullptr)) {
HILOG_ERROR(LOG_CORE, "%s:so filename invalid, errno=%d", __func__, errno);
return false;
}
if (access(path_.c_str(), F_OK) != 0) {
int32_t ret = mkdir(path_.c_str(), 0777);
CHECK_TRUE(ret == 0, false, "FileCache: mkdir failed(%s), error(%d)!", path_.c_str(), errno);
}
std::string path = path_ + file;
fp_ = fopen(path.c_str(), "wb+");
fp_ = fopen(realPath, "wb+");
CHECK_NOTNULL(fp_, -1, "FileCache: open(%s) Failed, errno(%d)", path.c_str(), errno);
return true;

View File

@ -395,6 +395,7 @@ bool HilogPlugin::StringToL(const char* word, long& value)
bool HilogPlugin::TimeStringToNS(const char* data, struct timespec *tsTime)
{
struct tm tmTime = {0};
struct tm* pTM = nullptr;
time_t timetTime;
char* end = nullptr;
char* pTmp = nullptr;
@ -403,7 +404,7 @@ bool HilogPlugin::TimeStringToNS(const char* data, struct timespec *tsTime)
long fixHour;
nSeconds = time(nullptr);
struct tm* pTM = localtime(&nSeconds);
localtime_r(&nSeconds, pTM);
if (pTM == nullptr) {
const int bufSize = 1024;
char buf[bufSize] = { 0 };