mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miko Larsson <mikoxyzzz@gmail.com>
To: minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org,
	axboe@kernel.dk, linux-kernel@vger.kernel.org,
	linux-block@vger.kernel.org
Cc: Miko Larsson <mikoxyzzz@gmail.com>
Subject: [PATCH 2/2] zram: zram_drv: replace strlcpy with strscpy
Date: Wed, 15 Dec 2021 20:21:28 +0100	[thread overview]
Message-ID: <20211215192128.108967-3-mikoxyzzz@gmail.com> (raw)
In-Reply-To: <20211215192128.108967-1-mikoxyzzz@gmail.com>

strlcpy shouldn't be used; strscpy should be used instead.

Signed-off-by: Miko Larsson <mikoxyzzz@gmail.com>
---
 drivers/block/zram/zram_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 464ef53adcbc..b1774d04a6ea 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -500,7 +500,7 @@ static ssize_t backing_dev_store(struct device *dev,
 		goto out;
 	}
 
-	strlcpy(file_name, buf, PATH_MAX);
+	strscpy(file_name, buf, PATH_MAX);
 	/* ignore trailing newline */
 	sz = strlen(file_name);
 	if (sz > 0 && file_name[sz - 1] == '\n')
@@ -1034,7 +1034,7 @@ static ssize_t comp_algorithm_store(struct device *dev,
 	char compressor[ARRAY_SIZE(zram->compressor)];
 	size_t sz;
 
-	strlcpy(compressor, buf, sizeof(compressor));
+	strscpy(compressor, buf, sizeof(compressor));
 	/* ignore trailing newline */
 	sz = strlen(compressor);
 	if (sz > 0 && compressor[sz - 1] == '\n')
@@ -1988,7 +1988,7 @@ static int zram_add(void)
 	if (ret)
 		goto out_cleanup_disk;
 
-	strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor));
+	strscpy(zram->compressor, default_compressor, sizeof(zram->compressor));
 
 	zram_debugfs_register(zram);
 	pr_info("Added device: %s\n", zram->disk->disk_name);
-- 
2.34.1


  parent reply	other threads:[~2021-12-15 19:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 19:21 [PATCH 0/2] zram: zram_drv: Fix some formatting problems Miko Larsson
2021-12-15 19:21 ` [PATCH 1/2] zram: zram_drv: add SPDX license identifiers Miko Larsson
2021-12-16 10:12   ` Christoph Hellwig
2021-12-15 19:21 ` Miko Larsson [this message]
2021-12-16 10:14   ` [PATCH 2/2] zram: zram_drv: replace strlcpy with strscpy Christoph Hellwig
2021-12-16 15:00     ` Miko Larsson
2021-12-16 17:52       ` Christoph Hellwig
2021-12-16 17:52         ` Christoph Hellwig

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=20211215192128.108967-3-mikoxyzzz@gmail.com \
    --to=mikoxyzzz@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=senozhatsky@chromium.org \
    /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

all inboxes | Powered by JetHome®