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>
return fstype;
mounts = fopen(proc_mounts, "r");
+ if (!mounts)
+ return NULL;
+
while ((nread = getline(&mountstr, &len, mounts)) != -1) {
found = false;
}
if (found)
- strncpy(fstype, tmp, sizeof(fstype));
+ strncpy(fstype, tmp, sizeof(fstype) - 1);
+ fstype[sizeof(fstype) - 1]= '\0';
free(mountstr);
fclose(mounts);