From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bart Van Assche Subject: [PATCH 3/5] libmultipath: Zero-terminate sysfs_attr_get_value() result Date: Fri, 18 Jul 2014 14:53:39 +0200 Message-ID: <53C918D3.7060908@acm.org> References: <53C91871.9070402@acm.org> Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53C91871.9070402@acm.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: christophe.varoqui@opensvc.com Cc: device-mapper development , Sebastian Herbszt List-Id: dm-devel.ids The callers of sysfs_attr_get_value() expect a '\0'-terminated string. Hence terminate the string returned by this function with '\0'. Detected by Valgrind. Signed-off-by: Bart Van Assche --- libmultipath/sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c index e5834f9..f42cda8 100644 --- a/libmultipath/sysfs.c +++ b/libmultipath/sysfs.c @@ -88,6 +88,8 @@ ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name, } else if (size == value_len) { condlog(4, "overflow while reading from %s", devpath); size = 0; + } else { + value[size] = '\0'; } close(fd); -- 1.8.4.5