Coverity warned that readlink() results aren't necessarily 0-terminated.

Signed-off-by: Martin Wilck <[email protected]>
---
 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

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Reply via email to