diff options
author | Daniel Golle <daniel@makrotopia.org> | 2021-08-15 11:52:20 +0100 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2021-08-15 15:16:16 +0100 |
commit | 040fecc1c14f812c0f8bdc3426366539ad88fe64 (patch) | |
tree | 772a12f6e948141055c4eb22e6545a2fee473a63 /system.c | |
parent | 2562e2b38d14fb1f337202feb6376fd447f30222 (diff) | |
download | procd-040fecc1c14f812c0f8bdc3426366539ad88fe64.tar.gz |
system: fix issues reported by Coverity
Coverity CID: 1490346 Buffer not null terminated
Coverity CID: 1490345 Dereference null return value
Fixes: 9f233f5 ("system: make rootfs type accessible through board call")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'system.c')
-rw-r--r-- | system.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -60,6 +60,9 @@ static const char *system_rootfs_type(void) { return fstype; mounts = fopen(proc_mounts, "r"); + if (!mounts) + return NULL; + while ((nread = getline(&mountstr, &len, mounts)) != -1) { found = false; @@ -101,8 +104,9 @@ static const char *system_rootfs_type(void) { } if (found) - strncpy(fstype, tmp, sizeof(fstype)); + strncpy(fstype, tmp, sizeof(fstype) - 1); + fstype[sizeof(fstype) - 1]= '\0'; free(mountstr); fclose(mounts); |