Skip to content

Commit f85267d

Browse files
kotopesutilityrocallahan
authored andcommitted
src/record_syscall.cc: check the result of read()
1 parent 630be70 commit f85267d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/record_syscall.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6210,9 +6210,10 @@ static bool os_has_broken_zfs() {
62106210
closedir(zfs_dir);
62116211
char version[50];
62126212
memset(version, 0, sizeof(version));
6213-
read(version_file_fd, version, sizeof(version) - 1);
6213+
int read_res = read(version_file_fd, version, sizeof(version) - 1);
62146214
int zfs_major = 0, zfs_minor = 0, zfs_patch = 0;
6215-
if (3 != sscanf(version, "%d.%d.%d", &zfs_major, &zfs_minor, &zfs_patch)) {
6215+
if (read_res == -1 ||
6216+
3 != sscanf(version, "%d.%d.%d", &zfs_major, &zfs_minor, &zfs_patch)) {
62166217
LOG(warn)
62176218
<< "Failed to parse /sys/module/zfs/version; assuming ZFS is broken";
62186219
return true;

0 commit comments

Comments
 (0)