All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Lukasz Dorau <lukasz.dorau@intel.com>
Cc: linux-raid@vger.kernel.org, dan.j.williams@intel.com,
	marcin.labun@intel.com, ed.ciechanowski@intel.com
Subject: Re: [PATCH] imsm: fix: prevent segfault in mark_failure
Date: Thu, 20 Oct 2011 13:00:00 +1100	[thread overview]
Message-ID: <20111020130000.32b245c6@notabene.brown> (raw)
In-Reply-To: <20111019095148.6240.80135.stgit@gklab-128-085.igk.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

On Wed, 19 Oct 2011 11:51:48 +0200 Lukasz Dorau <lukasz.dorau@intel.com>
wrote:

> Using an array of chars without the terminating null byte
> as a parameter of sprintf() function causes segfault
> when dealing with SAS drives (with 20-digits serial number).
> The memcpy() function is used instead.
> 
> Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
> ---
>  super-intel.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/super-intel.c b/super-intel.c
> index 401c701..2c1bf05 100644
> --- a/super-intel.c
> +++ b/super-intel.c
> @@ -6015,7 +6015,9 @@ static int mark_failure(struct imsm_dev *dev, struct imsm_disk *disk, int idx)
>  	if (is_failed(disk) && (ord & IMSM_ORD_REBUILD))
>  		return 0;
>  
> -	sprintf(buf, "%s:0", disk->serial);
> +	memcpy(buf, disk->serial, MAX_RAID_SERIAL_LEN);
> +	buf[MAX_RAID_SERIAL_LEN] = '\000';
> +	strcat(buf, ":0");
>  	if ((len = strlen(buf)) >= MAX_RAID_SERIAL_LEN)
>  		shift = len - MAX_RAID_SERIAL_LEN + 1;
>  	strncpy((char *)disk->serial, &buf[shift], MAX_RAID_SERIAL_LEN);


Applied. Thanks,

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

      reply	other threads:[~2011-10-20  2:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-19  9:51 [PATCH] imsm: fix: prevent segfault in mark_failure Lukasz Dorau
2011-10-20  2:00 ` NeilBrown [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=20111020130000.32b245c6@notabene.brown \
    --to=neilb@suse.de \
    --cc=dan.j.williams@intel.com \
    --cc=ed.ciechanowski@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=lukasz.dorau@intel.com \
    --cc=marcin.labun@intel.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.