fix: solve safe issues

This commit is contained in:
saturneric 2024-05-03 21:08:04 +02:00
parent 2596468c8a
commit 149d2789db
8 changed files with 14 additions and 10 deletions

View File

@ -106,7 +106,7 @@ class Event::Impl {
static_cast<GFModuleEvent*>(SecureMalloc(sizeof(GFModuleEvent)));
event->id = GFStrDup(event_identifier_);
event->triggger_id = GFStrDup(trigger_uuid_);
event->trigger_id = GFStrDup(trigger_uuid_);
GFModuleEventParam* l_param = nullptr;
GFModuleEventParam* p_param;
@ -121,7 +121,7 @@ class Event::Impl {
p_param->value = GFStrDup(data.second);
p_param->next = nullptr;
l_param->next = p_param;
if (l_param != nullptr) l_param->next = p_param;
l_param = p_param;
}

View File

@ -121,15 +121,15 @@ class Module::Impl {
}
GF_CORE_LOG_INFO(
"module loaded, id: {}, verison: {}, "
"module loaded, id: {}, version: {}, "
"sdk version: {}, qt env version: {}, hash: {}, path: {}",
identifier_, version_, gf_sdk_ver_, qt_env_ver_, module_hash_,
module_library_path_);
::GFModuleMetaData* p_meta_data = get_metadata_api_();
::GFModuleMetaData* l_meta_data;
while (p_meta_data != nullptr) {
::GFModuleMetaData* l_meta_data;
meta_data_[QString::fromUtf8(p_meta_data->key)] =
QString::fromUtf8(p_meta_data->value);
l_meta_data = p_meta_data;

View File

@ -202,7 +202,7 @@ auto CalculateBinaryChacksum(const QString& path) -> QString {
// read data by chunks
const qint64 buffer_size = 8192; // Define a suitable buffer size
while (!f.atEnd()) {
QByteArray buffer = f.read(buffer_size);
QByteArray const buffer = f.read(buffer_size);
if (buffer.isEmpty()) {
GF_CORE_LOG_ERROR("error reading file {} during checksum calculation",
path.toStdString());

View File

@ -262,7 +262,7 @@ auto CalculateBinaryChacksum(const QString &path) -> std::optional<QString> {
// read data by chunks
const qint64 buffer_size = 8192; // Define a suitable buffer size
while (!f.atEnd()) {
QByteArray buffer = f.read(buffer_size);
QByteArray const buffer = f.read(buffer_size);
if (buffer.isEmpty()) {
GFModuleLogError(
fmt::format("error reading file {} during checksum calculation",

View File

@ -90,6 +90,7 @@ void GFExecuteCommandBatchSync(int32_t context_size,
auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleStrDup(const char* src) -> char* {
auto len = strlen(src);
if (len > kGfStrlenMax) return nullptr;
char* dst = static_cast<char*>(GFAllocateMemory((len + 1) * sizeof(char)));
memcpy(dst, src, len);

View File

@ -28,12 +28,15 @@
#pragma once
#include <stdint.h>
#include <cstddef>
#include <cstdint>
#include "GFSDKExport.h"
extern "C" {
constexpr int32_t kGfStrlenMax = static_cast<const int32_t>(1024 * 8);
using GFCommandExeucteCallback = void (*)(void* data, int errcode,
const char* out, const char* err);

View File

@ -48,7 +48,7 @@ struct GFModuleEventParam {
struct GFModuleEvent {
const char *id;
const char *triggger_id;
const char *trigger_id;
GFModuleEventParam *params;
};

View File

@ -77,14 +77,14 @@ void WaitEnvCheckingProcess() {
&QEventLoop::quit);
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();
exit(0);
});
auto env_state =
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);
// check twice to avoid some unlucky sitations