diff options
author | Robert Evans <evansr@google.com> | 2024-03-29 21:59:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 21:59:23 +0000 |
commit | 2553f94c4299aaf31c5ceea4bfbfcc811cf76513 (patch) | |
tree | fa5c149309de789de7b01ba01ceefae82fb407e1 | |
parent | cfb96c772b8448dca6eaeb66a540b8bb39c9908c (diff) | |
download | src-2553f94c4299aaf31c5ceea4bfbfcc811cf76513.tar.gz src-2553f94c4299aaf31c5ceea4bfbfcc811cf76513.zip |
Fix buffer underflow if sysfs file is empty
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Jason Lee <jasonlee@lanl.gov>
Signed-off-by: Robert Evans <evansr@google.com>
Closes #16028
Closes #16035
-rw-r--r-- | cmd/zpool/os/linux/zpool_vdev_os.c | 2 |
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 006a3a7d8e01..80627b58211c 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); |