[dm-devel] [PATCH 04/12] libmultipath(coverity): make sure readlink result is 0-terminated
Martin Wilck
mwilck at suse.com
Tue Jan 8 22:54:01 UTC 2019
Coverity warned that readlink() results aren't necessarily 0-terminated.
Signed-off-by: Martin Wilck <mwilck at suse.com>
---
libmultipath/util.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libmultipath/util.c b/libmultipath/util.c
index 944c632..5b838d5 100644
--- a/libmultipath/util.c
+++ b/libmultipath/util.c
@@ -176,6 +176,7 @@ int devt2devname(char *devname, int devname_len, char *devt)
if (stat("/sys/dev/block", &statbuf) == 0) {
/* Newer kernels have /sys/dev/block */
sprintf(block_path,"/sys/dev/block/%u:%u", major, minor);
+ dev[FILE_NAME_SIZE - 1] = '\0';
if (lstat(block_path, &statbuf) == 0) {
if (S_ISLNK(statbuf.st_mode) &&
readlink(block_path, dev, FILE_NAME_SIZE-1) > 0) {
--
2.19.2
More information about the dm-devel
mailing list