mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 17:16:50 +08:00
[misc]: Terminate soc_name to fix out of bounds
1. Terminate soc_name string to fix memory out of bounds 2. Fix all snprintf/strnlen warning Change-Id: I4525c6e289a00d1509bc30ee69545d92f2f4b9cb Signed-off-by: Shunqian Zheng <zhengsq@rock-chips.com>
This commit is contained in:

committed by
Herman Chen

parent
32689b3708
commit
9464af395b
@@ -585,7 +585,7 @@ MppBufferGroupImpl *mpp_buffer_get_misc_group(MppBufferMode mode, MppBufferType
|
|||||||
AutoMutex auto_lock(MppBufferService::get_lock());
|
AutoMutex auto_lock(MppBufferService::get_lock());
|
||||||
MppBufferGroupImpl *misc = MppBufferService::get_instance()->get_misc(mode, type);
|
MppBufferGroupImpl *misc = MppBufferService::get_instance()->get_misc(mode, type);
|
||||||
if (NULL == misc) {
|
if (NULL == misc) {
|
||||||
char tag[16];
|
char tag[32];
|
||||||
RK_S32 offset = 0;
|
RK_S32 offset = 0;
|
||||||
|
|
||||||
offset += snprintf(tag + offset, sizeof(tag) - offset, "misc");
|
offset += snprintf(tag + offset, sizeof(tag) - offset, "misc");
|
||||||
|
@@ -206,13 +206,15 @@ static RK_S32 find_dir_in_path(char *path, const char *dir_name,
|
|||||||
return new_path_len;
|
return new_path_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAX_PATH_NAME_SIZE 256
|
||||||
|
|
||||||
static RK_S32 check_sysfs_iommu()
|
static RK_S32 check_sysfs_iommu()
|
||||||
{
|
{
|
||||||
RK_U32 i = 0;
|
RK_U32 i = 0;
|
||||||
RK_U32 dts_info_found = 0;
|
RK_U32 dts_info_found = 0;
|
||||||
RK_U32 ion_info_found = 0;
|
RK_U32 ion_info_found = 0;
|
||||||
RK_S32 ret = ION_DETECT_IOMMU_DISABLE;
|
RK_S32 ret = ION_DETECT_IOMMU_DISABLE;
|
||||||
char path[256];
|
char path[MAX_PATH_NAME_SIZE];
|
||||||
static char *dts_devices[] = {
|
static char *dts_devices[] = {
|
||||||
"vpu_service",
|
"vpu_service",
|
||||||
"hevc_service",
|
"hevc_service",
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
#include "mpp_common.h"
|
#include "mpp_common.h"
|
||||||
#include "mpp_platform.h"
|
#include "mpp_platform.h"
|
||||||
|
|
||||||
#define MAX_SOC_NAME_LENGTH 64
|
#define MAX_SOC_NAME_LENGTH 128
|
||||||
|
|
||||||
class MppPlatformService;
|
class MppPlatformService;
|
||||||
|
|
||||||
@@ -195,6 +195,7 @@ MppPlatformService::MppPlatformService()
|
|||||||
snprintf(soc_name, MAX_SOC_NAME_LENGTH, "unknown");
|
snprintf(soc_name, MAX_SOC_NAME_LENGTH, "unknown");
|
||||||
soc_name_len = read(fd, soc_name, MAX_SOC_NAME_LENGTH - 1);
|
soc_name_len = read(fd, soc_name, MAX_SOC_NAME_LENGTH - 1);
|
||||||
if (soc_name_len > 0) {
|
if (soc_name_len > 0) {
|
||||||
|
soc_name[soc_name_len] = '\0';
|
||||||
/* replacing the termination character to space */
|
/* replacing the termination character to space */
|
||||||
for (char *ptr = soc_name;; ptr = soc_name) {
|
for (char *ptr = soc_name;; ptr = soc_name) {
|
||||||
ptr += strnlen(soc_name, MAX_SOC_NAME_LENGTH);
|
ptr += strnlen(soc_name, MAX_SOC_NAME_LENGTH);
|
||||||
|
@@ -264,7 +264,8 @@ static void *mpp_timer_thread(void *ctx)
|
|||||||
if (fd_cnt && (events.events & EPOLLIN) && (events.data.fd == timer_fd)) {
|
if (fd_cnt && (events.events & EPOLLIN) && (events.data.fd == timer_fd)) {
|
||||||
RK_U64 exp = 0;
|
RK_U64 exp = 0;
|
||||||
|
|
||||||
read(timer_fd, &exp, sizeof(exp));
|
ssize_t cnt = read(timer_fd, &exp, sizeof(exp));
|
||||||
|
mpp_assert(cnt == sizeof(exp));
|
||||||
impl->func(impl->ctx);
|
impl->func(impl->ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,7 +309,7 @@ MppTimer mpp_timer_get(const char *name)
|
|||||||
impl->initial = 1000;
|
impl->initial = 1000;
|
||||||
impl->interval = 1000;
|
impl->interval = 1000;
|
||||||
impl->check = timer_name;
|
impl->check = timer_name;
|
||||||
snprintf(impl->name, sizeof(impl->name) - 1, name, NULL);
|
snprintf(impl->name, sizeof(impl->name), name, NULL);
|
||||||
|
|
||||||
return impl;
|
return impl;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
@@ -68,7 +68,7 @@ MPP_RET mpi_enc_test_cmd_update_by_args(MpiEncTestArgs* cmd, int argc, char **ar
|
|||||||
size_t len = strnlen(next, MAX_FILE_NAME_LENGTH);
|
size_t len = strnlen(next, MAX_FILE_NAME_LENGTH);
|
||||||
if (len) {
|
if (len) {
|
||||||
cmd->file_input = mpp_calloc(char, len + 1);
|
cmd->file_input = mpp_calloc(char, len + 1);
|
||||||
strncpy(cmd->file_input, next, len);
|
strcpy(cmd->file_input, next);
|
||||||
name_to_frame_format(cmd->file_input, &cmd->format);
|
name_to_frame_format(cmd->file_input, &cmd->format);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -81,7 +81,7 @@ MPP_RET mpi_enc_test_cmd_update_by_args(MpiEncTestArgs* cmd, int argc, char **ar
|
|||||||
size_t len = strnlen(next, MAX_FILE_NAME_LENGTH);
|
size_t len = strnlen(next, MAX_FILE_NAME_LENGTH);
|
||||||
if (len) {
|
if (len) {
|
||||||
cmd->file_output = mpp_calloc(char, len + 1);
|
cmd->file_output = mpp_calloc(char, len + 1);
|
||||||
strncpy(cmd->file_output, next, len);
|
strcpy(cmd->file_output, next);
|
||||||
name_to_coding_type(cmd->file_output, &cmd->type);
|
name_to_coding_type(cmd->file_output, &cmd->type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user