xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Keir Fraser <keir.xen@gmail.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Paul Durrant <Paul.Durrant@citrix.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH] hvmloader/smbios: Change strncpy to memcpy for anchor strings.
Date: Thu, 26 Sep 2013 14:52:08 +0100	[thread overview]
Message-ID: <52443C08.5050108@citrix.com> (raw)
In-Reply-To: <CE6723E4.34413%keir.xen@gmail.com>

On 24/09/13 11:11, Keir Fraser wrote:
> 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
>
>

So what is the verdict here?  I changed 4 to sizeof to match the
prevailing style of other anchor strings in hvmloader.

I can resubmit and change back to hard coded numbers if that would cause
the patch to be accepted.

~Andrew

  parent reply	other threads:[~2013-09-26 13:52 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
2013-09-24 10:18       ` Jan Beulich
2013-09-26 13:52       ` Andrew Cooper [this message]
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=52443C08.5050108@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Paul.Durrant@citrix.com \
    --cc=keir.xen@gmail.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).