diff --git a/src/detection/diskio/diskio_linux.c b/src/detection/diskio/diskio_linux.c index fc9ffe043..e865581c2 100644 --- a/src/detection/diskio/diskio_linux.c +++ b/src/detection/diskio/diskio_linux.c @@ -23,8 +23,11 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) char pathSysBlock[PATH_MAX]; snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s", devName); - char pathSysDeviceReal[PATH_MAX] = ""; - readlink(pathSysBlock, pathSysDeviceReal, sizeof(pathSysDeviceReal) - 1); + char pathSysDeviceReal[PATH_MAX]; + ssize_t pathLength = readlink(pathSysBlock, pathSysDeviceReal, sizeof(pathSysDeviceReal) - 1); + if (pathLength < 0) + continue; + pathSysDeviceReal[pathLength] = '\0'; if (strstr(pathSysDeviceReal, "/virtual/")) // virtual device continue; diff --git a/src/detection/physicaldisk/physicaldisk_linux.c b/src/detection/physicaldisk/physicaldisk_linux.c index ac4311e5a..b94667731 100644 --- a/src/detection/physicaldisk/physicaldisk_linux.c +++ b/src/detection/physicaldisk/physicaldisk_linux.c @@ -23,8 +23,11 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) char pathSysBlock[PATH_MAX]; snprintf(pathSysBlock, PATH_MAX, "/sys/block/%s", devName); - char pathSysDeviceReal[PATH_MAX] = ""; - readlink(pathSysBlock, pathSysDeviceReal, sizeof(pathSysDeviceReal) - 1); + char pathSysDeviceReal[PATH_MAX]; + ssize_t pathLength = readlink(pathSysBlock, pathSysDeviceReal, sizeof(pathSysDeviceReal) - 1); + if (pathLength < 0) + continue; + pathSysDeviceReal[pathLength] = '\0'; if (strstr(pathSysDeviceReal, "/virtual/")) // virtual device continue;