From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
To: Jens Axboe <axboe@kernel.dk>, linux-kernel@vger.kernel.org
Cc: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Subject: [PATCH] block: elevator.c: Cleaning up missing null-terminate in conjunction with strncpy
Date: Sun, 27 Jul 2014 01:15:41 +0200 [thread overview]
Message-ID: <1406416541-8984-1-git-send-email-rickard_strandqvist@spectrumdigital.se> (raw)
Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
And set a string to be empty from the start.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
block/elevator.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/elevator.c b/block/elevator.c
index 24c28b6..ad17774 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -118,7 +118,7 @@ static struct elevator_type *elevator_get(const char *name, bool try_loading)
return e;
}
-static char chosen_elevator[ELV_NAME_MAX];
+static char chosen_elevator[ELV_NAME_MAX] = "";
static int __init elevator_setup(char *str)
{
@@ -126,7 +126,7 @@ static int __init elevator_setup(char *str)
* Be backwards-compatible with previous kernels, so users
* won't get the wrong elevator.
*/
- strncpy(chosen_elevator, str, sizeof(chosen_elevator) - 1);
+ strlcpy(chosen_elevator, str, sizeof(chosen_elevator));
return 1;
}
--
1.7.10.4
next reply other threads:[~2014-07-26 23:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-26 23:15 Rickard Strandqvist [this message]
2014-07-28 14:32 ` Jeff Moyer
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=1406416541-8984-1-git-send-email-rickard_strandqvist@spectrumdigital.se \
--to=rickard_strandqvist@spectrumdigital.se \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.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®