From: Keir Fraser <keir.xen@gmail.com>
To: Jan Beulich <JBeulich@suse.com>, Paul Durrant <Paul.Durrant@citrix.com>
Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>,
xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] hvmloader/smbios: Change strncpy to memcpy for anchor strings.
Date: Tue, 24 Sep 2013 11:11:32 +0100 [thread overview]
Message-ID: <CE6723E4.34413%keir.xen@gmail.com> (raw)
In-Reply-To: <52417A0202000078000F5CD4@nat28.tlf.novell.com>
On 24/09/2013 10:39, "Jan Beulich" <JBeulich@suse.com> wrote:
>>> - strncpy(ep->anchor_string, "_SM_", 4);
>>> + memcpy(ep->anchor_string, "_SM_", sizeof(ep->anchor_string));
>>
>> Why the change from 4 to sizeof(ep->anchor_string) here (and similar below)?
>> Setting the copy length based on the size of the destination rather than the
>> source seems like the wrong thing to do.
>
> One can argue either way here:
> - passing the destination's size guarantees no memory corruption
> - passing the source's size guarantees no uninitialized memory
>
> Since the structure fields involved here aren't going to change,
> either way is fine imo.
As was the unadorned number 4, imo.
-- Keir
next prev parent reply other threads:[~2013-09-24 10:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-23 18:22 [PATCH] hvmloader/smbios: Change strncpy to memcpy for anchor strings Andrew Cooper
2013-09-24 9:14 ` Paul Durrant
2013-09-24 9:39 ` Jan Beulich
2013-09-24 10:11 ` Keir Fraser [this message]
2013-09-24 10:18 ` Jan Beulich
2013-09-26 13:52 ` Andrew Cooper
2013-09-26 19:13 ` Keir Fraser
2013-09-24 9:40 ` Jan Beulich
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=CE6723E4.34413%keir.xen@gmail.com \
--to=keir.xen@gmail.com \
--cc=Andrew.Cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=Paul.Durrant@citrix.com \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).