linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuhong Yuan <hslester96@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Adam Radford <aradford@gmail.com>,
	"James E . J . Bottomley" <jejb@linux.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Chuhong Yuan <hslester96@gmail.com>
Subject: [PATCH] scsi: 3w-sas: Fix unterminated strncpy
Date: Tue, 30 Jul 2019 16:40:47 +0800	[thread overview]
Message-ID: <20190730084047.26482-1-hslester96@gmail.com> (raw)

strncpy(dest, src, strlen(src)) leads to unterminated
dest, which is dangerous.
Here driver_version's len is 32 and TW_DRIVER_VERSION
is shorter than 32.
Therefore strcpy is OK.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 drivers/scsi/3w-sas.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index dda6fa857709..96f529c613a6 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -1328,7 +1328,7 @@ static int twl_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset)
 		}
 
 		/* Load rest of compatibility struct */
-		strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION));
+		strcpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION);
 		tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL;
 		tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH;
 		tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD;
-- 
2.20.1


             reply	other threads:[~2019-07-30  8:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30  8:40 Chuhong Yuan [this message]
2019-07-30 14:56 ` [PATCH] scsi: 3w-sas: Fix unterminated strncpy James Bottomley
2019-08-05  6:22   ` Chuhong Yuan

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=20190730084047.26482-1-hslester96@gmail.com \
    --to=hslester96@gmail.com \
    --cc=aradford@gmail.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).