mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Moyer <jmoyer@redhat.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Jens Axboe <axboe@kernel.dk>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: elevator.c:  Cleaning up missing null-terminate in conjunction with strncpy
Date: Mon, 28 Jul 2014 10:32:37 -0400	[thread overview]
Message-ID: <x49oaw9pn96.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <1406416541-8984-1-git-send-email-rickard_strandqvist@spectrumdigital.se> (Rickard Strandqvist's message of "Sun, 27 Jul 2014 01:15:41 +0200")

Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> writes:

> 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;
>  }

NACK.  bss is zeroed.

      reply	other threads:[~2014-07-28 14:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-26 23:15 Rickard Strandqvist
2014-07-28 14:32 ` Jeff Moyer [this message]

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=x49oaw9pn96.fsf@segfault.boston.devel.redhat.com \
    --to=jmoyer@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rickard_strandqvist@spectrumdigital.se \
    /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®