All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - lvmcache: fix strncpy len for wwid
Date: Thu,  1 Dec 2022 18:07:24 +0000 (GMT)	[thread overview]
Message-ID: <20221201180724.20E9B3858C52@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f80273a1071532115219ea7c23054e6bbb096039
Commit:        f80273a1071532115219ea7c23054e6bbb096039
Parent:        55b29c1c3d4b5c1366ec0a24fb680cfb81fc4961
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Thu Dec 1 10:03:06 2022 -0600
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Thu Dec 1 10:03:06 2022 -0600

lvmcache: fix strncpy len for wwid

---
 lib/cache/lvmcache.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 1ae63b3fc..ec32b3be9 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -654,13 +654,13 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
 
 		if (dev_is_mp) {
 			if ((wwid1 = dev_mpath_component_wwid(cmd, dev))) {
-				strncpy(wwid1_buf, wwid1, DEV_WWID_SIZE);
+				strncpy(wwid1_buf, wwid1, DEV_WWID_SIZE-1);
 				dev_mp = dev;
 				dev1 = dev;
 			}
 		} else {
 			if ((wwid1 = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID))) {
-				strncpy(wwid1_buf, wwid1, DEV_WWID_SIZE);
+				strncpy(wwid1_buf, wwid1, DEV_WWID_SIZE-1);
 				free((char *)wwid1);
 				dev1 = dev;
 			}
@@ -673,10 +673,10 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
 
 		if (dev_is_mp) {
 			if ((wwid = dev_mpath_component_wwid(cmd, dev)))
-				strncpy(wwid_buf, wwid, DEV_WWID_SIZE);
+				strncpy(wwid_buf, wwid, DEV_WWID_SIZE-1);
 		} else {
 			if ((wwid = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID))) {
-				strncpy(wwid_buf, wwid, DEV_WWID_SIZE);
+				strncpy(wwid_buf, wwid, DEV_WWID_SIZE-1);
 				free((char *)wwid);
 			}
 		}
@@ -692,7 +692,7 @@ static int _all_multipath_components(struct cmd_context *cmd, struct lvmcache_in
 			continue;
 
 		if (!wwid1_buf[0]) {
-			memcpy(wwid1_buf, wwid_buf, DEV_WWID_SIZE);
+			memcpy(wwid1_buf, wwid_buf, DEV_WWID_SIZE-1);
 			dev1 = dev;
 			continue;
 		}


                 reply	other threads:[~2022-12-01 18:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221201180724.20E9B3858C52@sourceware.org \
    --to=teigland@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.