Skip to content

Commit

Permalink
Fix buffer underflow if sysfs file is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Evans <[email protected]>

Fixes: openzfs#16028
  • Loading branch information
rrevans committed Mar 28, 2024
1 parent e39e20b commit 0dd1b29
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/zpool/os/linux/zpool_vdev_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ static char *zpool_sysfs_gets(char *path)
}

/* Remove trailing newline */
if (buf[count - 1] == '\n')
if (count > 0 && buf[count - 1] == '\n')
buf[count - 1] = 0;

close(fd);
Expand Down

0 comments on commit 0dd1b29

Please sign in to comment.