Skip to content

Commit 271b78b

Browse files
committed
Memory-safety related changes, fixes on string array looping
1 parent 2571f46 commit 271b78b

File tree

15 files changed

+37
-27
lines changed

15 files changed

+37
-27
lines changed

.vscode/c_cpp_properties.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@
4949
"compilerPath": "toolchain/toolchain.sigmastar-infinity6e/bin/arm-openipc-linux-gnueabihf-gcc",
5050
"cStandard": "c11"
5151
},{
52-
"name": "armhf-uclibc",
52+
"name": "armhf-musl",
5353
"includePath": ["${workspaceFolder}/**"],
5454
"defines": ["__arm__", "__ARM_PCS_VFP"],
55-
"compilerPath": "toolchain/toolchain.rockchip-rv11xx/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc",
55+
"compilerPath": "toolchain/toolchain.sigmastar-infinity6/bin/arm-openipc-linux-musleabihf-gcc",
5656
"cStandard": "c11"
5757
},{
58-
"name": "armhf-musl",
58+
"name": "armhf-uclibc",
5959
"includePath": ["${workspaceFolder}/**"],
6060
"defines": ["__arm__", "__ARM_PCS_VFP"],
61-
"compilerPath": "toolchain/toolchain.sigmastar-infinity6/bin/arm-openipc-linux-musleabihf-gcc",
61+
"compilerPath": "toolchain/toolchain.rockchip-rv11xx/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc",
6262
"cStandard": "c11"
6363
},{
6464
"name": "mips-musl",

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ In spite of these design choices, Divinus boasts numerous features that cater to
3333
| Hi3519V100[^10] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
3434
| Hi3519AV100 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
3535
| Hi3559AV100 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
36-
| RV11xx[^11] || | ✔️ | ✔️ ||
36+
| RV11xx[^11] || ✔️ | ✔️ | ✔️ ||
3737
| T31 series | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
3838
| infinity3[^12] ||||||
3939
| infinity6[^13] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |

src/app_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ enum ConfigError parse_app_config(void) {
283283
goto RET_ERR;
284284
parse_param_value(&ini, "system", "time_format", timefmt);
285285
if (EMPTY(timefmt))
286-
strcpy(timefmt, DEF_TIMEFMT);
286+
strncpy(timefmt, DEF_TIMEFMT, sizeof(timefmt) - 1);
287287
parse_int(&ini, "system", "watchdog", 0, INT_MAX, &app_config.watchdog);
288288

289289
err =

src/compat.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,23 @@ float __expf_finite(float x) { return expf(x); }
5555
int __fgetc_unlocked(FILE *stream) { return fgetc(stream); }
5656
double __log_finite(double x) { return log(x); }
5757

58-
#if !defined(__riscv) && !defined(__riscv__)
58+
#if !defined(__riscv) || !defined(__riscv__)
5959
void *mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) {
6060
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
6161
}
6262

63+
void *__mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off) {
64+
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
65+
}
6366
#if !(defined(__ARM_PCS_VFP) && defined(__UCLIBC__))
6467
void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off) {
6568
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
6669
}
6770
#endif
6871
#else
72+
void *__mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off) {
73+
return (void*)syscall(SYS_mmap, start, len, prot, flags, fd, off);
74+
}
6975
void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off) {
7076
return (void*)syscall(SYS_mmap, start, len, prot, flags, fd, off);
7177
}

src/hal/hisi/v1_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ void v1_sensor_deinit(void)
419419
int v1_sensor_init(char *name, char *obj)
420420
{
421421
char path[128];
422-
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s"};
422+
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s", NULL};
423423
char **dir = dirs;
424424

425425
while (*dir) {

src/hal/hisi/v2_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void v2_sensor_deinit(void)
448448
int v2_sensor_init(char *name, char *obj)
449449
{
450450
char path[128];
451-
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s"};
451+
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s", NULL};
452452
char **dir = dirs;
453453

454454
while (*dir) {

src/hal/hisi/v3_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ void v3_sensor_deinit(void)
469469
int v3_sensor_init(char *name, char *obj)
470470
{
471471
char path[128];
472-
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s"};
472+
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s", NULL};
473473
char **dir = dirs;
474474

475475
while (*dir) {

src/hal/hisi/v4_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ void v4_sensor_deinit(void)
581581
int v4_sensor_init(char *name, char *obj)
582582
{
583583
char path[128];
584-
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s"};
584+
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s", NULL};
585585
char **dir = dirs;
586586

587587
while (*dir) {

src/hal/plus/cvi_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ int cvi_sensor_init(char *name, char *obj)
491491
{
492492
char path[128];
493493
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s", "/usr/lib/%s",
494-
"/mnt/system/lib/%s", "/mnt/system/lib/libsns_full.so"};
494+
"/mnt/system/lib/%s", "/mnt/system/lib/libsns_full.so", NULL};
495495
char **dir = dirs;
496496

497497
while (*dir) {

src/hal/plus/rk_hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ int rk_sensor_find_v4l2_endpoint(void)
419419
fgets(line, 32, fp);
420420
fclose(fp);
421421

422-
if (!strncmp(line, "rkisp_mainpath", 14))
422+
if (EQUALS(line, "rkisp_mainpath"))
423423
{
424424
index = i;
425425
break;

0 commit comments

Comments
 (0)