mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-12 20:40:07 +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
@@ -23,7 +23,7 @@
|
||||
#include "mpp_common.h"
|
||||
#include "mpp_platform.h"
|
||||
|
||||
#define MAX_SOC_NAME_LENGTH 64
|
||||
#define MAX_SOC_NAME_LENGTH 128
|
||||
|
||||
class MppPlatformService;
|
||||
|
||||
@@ -195,9 +195,10 @@ MppPlatformService::MppPlatformService()
|
||||
snprintf(soc_name, MAX_SOC_NAME_LENGTH, "unknown");
|
||||
soc_name_len = read(fd, soc_name, MAX_SOC_NAME_LENGTH - 1);
|
||||
if (soc_name_len > 0) {
|
||||
soc_name[soc_name_len] = '\0';
|
||||
/* replacing the termination character to space */
|
||||
for (char *ptr = soc_name;; ptr = soc_name) {
|
||||
ptr += strnlen (soc_name, MAX_SOC_NAME_LENGTH);
|
||||
ptr += strnlen(soc_name, MAX_SOC_NAME_LENGTH);
|
||||
if (ptr >= soc_name + soc_name_len - 1)
|
||||
break;
|
||||
*ptr = ' ';
|
||||
|
Reference in New Issue
Block a user