fix: solve safe issues
This commit is contained in:
parent
2596468c8a
commit
149d2789db
@ -106,7 +106,7 @@ class Event::Impl {
|
|||||||
static_cast<GFModuleEvent*>(SecureMalloc(sizeof(GFModuleEvent)));
|
static_cast<GFModuleEvent*>(SecureMalloc(sizeof(GFModuleEvent)));
|
||||||
|
|
||||||
event->id = GFStrDup(event_identifier_);
|
event->id = GFStrDup(event_identifier_);
|
||||||
event->triggger_id = GFStrDup(trigger_uuid_);
|
event->trigger_id = GFStrDup(trigger_uuid_);
|
||||||
|
|
||||||
GFModuleEventParam* l_param = nullptr;
|
GFModuleEventParam* l_param = nullptr;
|
||||||
GFModuleEventParam* p_param;
|
GFModuleEventParam* p_param;
|
||||||
@ -121,7 +121,7 @@ class Event::Impl {
|
|||||||
p_param->value = GFStrDup(data.second);
|
p_param->value = GFStrDup(data.second);
|
||||||
p_param->next = nullptr;
|
p_param->next = nullptr;
|
||||||
|
|
||||||
l_param->next = p_param;
|
if (l_param != nullptr) l_param->next = p_param;
|
||||||
l_param = p_param;
|
l_param = p_param;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,15 +121,15 @@ class Module::Impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GF_CORE_LOG_INFO(
|
GF_CORE_LOG_INFO(
|
||||||
"module loaded, id: {}, verison: {}, "
|
"module loaded, id: {}, version: {}, "
|
||||||
"sdk version: {}, qt env version: {}, hash: {}, path: {}",
|
"sdk version: {}, qt env version: {}, hash: {}, path: {}",
|
||||||
identifier_, version_, gf_sdk_ver_, qt_env_ver_, module_hash_,
|
identifier_, version_, gf_sdk_ver_, qt_env_ver_, module_hash_,
|
||||||
module_library_path_);
|
module_library_path_);
|
||||||
|
|
||||||
::GFModuleMetaData* p_meta_data = get_metadata_api_();
|
::GFModuleMetaData* p_meta_data = get_metadata_api_();
|
||||||
::GFModuleMetaData* l_meta_data;
|
|
||||||
|
|
||||||
while (p_meta_data != nullptr) {
|
while (p_meta_data != nullptr) {
|
||||||
|
::GFModuleMetaData* l_meta_data;
|
||||||
meta_data_[QString::fromUtf8(p_meta_data->key)] =
|
meta_data_[QString::fromUtf8(p_meta_data->key)] =
|
||||||
QString::fromUtf8(p_meta_data->value);
|
QString::fromUtf8(p_meta_data->value);
|
||||||
l_meta_data = p_meta_data;
|
l_meta_data = p_meta_data;
|
||||||
|
@ -202,7 +202,7 @@ auto CalculateBinaryChacksum(const QString& path) -> QString {
|
|||||||
// read data by chunks
|
// read data by chunks
|
||||||
const qint64 buffer_size = 8192; // Define a suitable buffer size
|
const qint64 buffer_size = 8192; // Define a suitable buffer size
|
||||||
while (!f.atEnd()) {
|
while (!f.atEnd()) {
|
||||||
QByteArray buffer = f.read(buffer_size);
|
QByteArray const buffer = f.read(buffer_size);
|
||||||
if (buffer.isEmpty()) {
|
if (buffer.isEmpty()) {
|
||||||
GF_CORE_LOG_ERROR("error reading file {} during checksum calculation",
|
GF_CORE_LOG_ERROR("error reading file {} during checksum calculation",
|
||||||
path.toStdString());
|
path.toStdString());
|
||||||
|
@ -262,7 +262,7 @@ auto CalculateBinaryChacksum(const QString &path) -> std::optional<QString> {
|
|||||||
// read data by chunks
|
// read data by chunks
|
||||||
const qint64 buffer_size = 8192; // Define a suitable buffer size
|
const qint64 buffer_size = 8192; // Define a suitable buffer size
|
||||||
while (!f.atEnd()) {
|
while (!f.atEnd()) {
|
||||||
QByteArray buffer = f.read(buffer_size);
|
QByteArray const buffer = f.read(buffer_size);
|
||||||
if (buffer.isEmpty()) {
|
if (buffer.isEmpty()) {
|
||||||
GFModuleLogError(
|
GFModuleLogError(
|
||||||
fmt::format("error reading file {} during checksum calculation",
|
fmt::format("error reading file {} during checksum calculation",
|
||||||
|
@ -90,6 +90,7 @@ void GFExecuteCommandBatchSync(int32_t context_size,
|
|||||||
|
|
||||||
auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleStrDup(const char* src) -> char* {
|
auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleStrDup(const char* src) -> char* {
|
||||||
auto len = strlen(src);
|
auto len = strlen(src);
|
||||||
|
if (len > kGfStrlenMax) return nullptr;
|
||||||
|
|
||||||
char* dst = static_cast<char*>(GFAllocateMemory((len + 1) * sizeof(char)));
|
char* dst = static_cast<char*>(GFAllocateMemory((len + 1) * sizeof(char)));
|
||||||
memcpy(dst, src, len);
|
memcpy(dst, src, len);
|
||||||
|
@ -28,12 +28,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include "GFSDKExport.h"
|
#include "GFSDKExport.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
constexpr int32_t kGfStrlenMax = static_cast<const int32_t>(1024 * 8);
|
||||||
|
|
||||||
using GFCommandExeucteCallback = void (*)(void* data, int errcode,
|
using GFCommandExeucteCallback = void (*)(void* data, int errcode,
|
||||||
const char* out, const char* err);
|
const char* out, const char* err);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ struct GFModuleEventParam {
|
|||||||
|
|
||||||
struct GFModuleEvent {
|
struct GFModuleEvent {
|
||||||
const char *id;
|
const char *id;
|
||||||
const char *triggger_id;
|
const char *trigger_id;
|
||||||
GFModuleEventParam *params;
|
GFModuleEventParam *params;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,14 +77,14 @@ void WaitEnvCheckingProcess() {
|
|||||||
&QEventLoop::quit);
|
&QEventLoop::quit);
|
||||||
|
|
||||||
QApplication::connect(waiting_dialog, &QProgressDialog::canceled, [=]() {
|
QApplication::connect(waiting_dialog, &QProgressDialog::canceled, [=]() {
|
||||||
GF_UI_LOG_DEBUG("cancel clicked on wairing dialog");
|
GF_UI_LOG_DEBUG("cancel clicked on waiting dialog");
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
exit(0);
|
exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto env_state =
|
auto env_state =
|
||||||
Module::RetrieveRTValueTypedOrDefault<>("core", "env.state.basic", 0);
|
Module::RetrieveRTValueTypedOrDefault<>("core", "env.state.basic", 0);
|
||||||
GF_UI_LOG_DEBUG("ui is ready to wating for env initialized, env_state: {}",
|
GF_UI_LOG_DEBUG("ui is ready to waiting for env initialized, env_state: {}",
|
||||||
env_state);
|
env_state);
|
||||||
|
|
||||||
// check twice to avoid some unlucky sitations
|
// check twice to avoid some unlucky sitations
|
||||||
|
Loading…
x
Reference in New Issue
Block a user