diff mbox

[2/6] libmultipath, alloc_path_with_pathinfo(): Ensure that pp->wwid is '\0'-terminated

Message ID 20180301192935.14643-3-bart.vanassche@wdc.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show

Commit Message

Bart Van Assche March 1, 2018, 7:29 p.m. UTC
Discovered by Coverity (CID 173257).

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 libmultipath/discovery.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Martin Wilck March 5, 2018, 4:11 p.m. UTC | #1
On Thu, 2018-03-01 at 11:29 -0800, Bart Van Assche wrote:
> Discovered by Coverity (CID 173257).
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>

Reviewed-by: Martin Wilck <mwilck@suse.com>

> ---
>  libmultipath/discovery.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
> index 4b31ddef23f0..fe50ce5062ea 100644
> --- a/libmultipath/discovery.c
> +++ b/libmultipath/discovery.c
> @@ -52,8 +52,8 @@ alloc_path_with_pathinfo (struct config *conf,
> struct udev_device *udevice,
>  	if (!pp)
>  		return PATHINFO_FAILED;
>  
> -	if(wwid)
> -		strncpy(pp->wwid, wwid, sizeof(pp->wwid));
> +	if (wwid)
> +		strlcpy(pp->wwid, wwid, sizeof(pp->wwid));
>  
>  	if (safe_sprintf(pp->dev, "%s", devname)) {
>  		condlog(0, "pp->dev too small");
diff mbox

Patch

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 4b31ddef23f0..fe50ce5062ea 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -52,8 +52,8 @@  alloc_path_with_pathinfo (struct config *conf, struct udev_device *udevice,
 	if (!pp)
 		return PATHINFO_FAILED;
 
-	if(wwid)
-		strncpy(pp->wwid, wwid, sizeof(pp->wwid));
+	if (wwid)
+		strlcpy(pp->wwid, wwid, sizeof(pp->wwid));
 
 	if (safe_sprintf(pp->dev, "%s", devname)) {
 		condlog(0, "pp->dev too small");