aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorRobert Evans <[email protected]>2024-03-29 17:59:23 -0400
committerTony Hutter <[email protected]>2024-04-29 13:50:05 -0700
commite0cfa1592da065fb0e0ba7579ea4d152ce099323 (patch)
tree53e3b2c5b6d4568af9aecad3412ca5250986f3c2 /cmd
parentd088fb7d24083988f38e4224a6ef9cc71c12a6a3 (diff)
Fix buffer underflow if sysfs file is empty
Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Jason Lee <[email protected]> Signed-off-by: Robert Evans <[email protected]> Closes #16028 Closes #16035
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zpool/os/linux/zpool_vdev_os.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cmd/zpool/os/linux/zpool_vdev_os.c b/cmd/zpool/os/linux/zpool_vdev_os.c
index 006a3a7d8..80627b582 100644
--- a/cmd/zpool/os/linux/zpool_vdev_os.c
+++ b/cmd/zpool/os/linux/zpool_vdev_os.c
@@ -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);