Linux RAID subsystem development
 help / color / mirror / Atom feed
From: "Tkaczyk, Mariusz" <mariusz.tkaczyk@linux.intel.com>
To: Nigel Croxon <ncroxon@redhat.com>,
	linux-raid <linux-raid@vger.kernel.org>
Subject: Re: [PATCH V3] Fix buffer size warning for strcpy
Date: Tue, 24 Aug 2021 09:35:08 +0200	[thread overview]
Message-ID: <92a90fb5-c9d7-92ea-2133-307fdb96e2a2@linux.intel.com> (raw)
In-Reply-To: <1c777af7-dda5-4332-74d0-0d4e1ba58031@linux.intel.com>

Hello Nigel,
It current form it is not working. See my finding below.

On 23.08.2021 17:36, Tkaczyk, Mariusz wrote:
> 
>> +        int l = strlen(ve->name);
i think that you want to use name instead of ve->name.
length of ve->name is zero after memset.

>> +        if (l > 16)
>> +            l = 16;
> I think that whole "if" statement can be replaced by:
> strnlen(ve->name, sizeof(ve->name))

I did a mistake here.
I want to suggest usage of:
l = strnlen(name, sizeof(ve->name));

>> +        memcpy(ve->name, name, l);
>> +    }
>
Thanks,
Mariusz

      reply	other threads:[~2021-08-24  7:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 14:35 [PATCH V3] Fix buffer size warning for strcpy Nigel Croxon
2021-08-23 15:36 ` Tkaczyk, Mariusz
2021-08-24  7:35   ` Tkaczyk, Mariusz [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=92a90fb5-c9d7-92ea-2133-307fdb96e2a2@linux.intel.com \
    --to=mariusz.tkaczyk@linux.intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=ncroxon@redhat.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