xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Keir Fraser <keir.xen@gmail.com>
To: Andrew Cooper <andrew.cooper3@citrix.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 20:13:19 +0100	[thread overview]
Message-ID: <CE6A45DF.3567D%keir.xen@gmail.com> (raw)
In-Reply-To: <52443C08.5050108@citrix.com>

On 26/09/2013 14:52, "Andrew Cooper" <andrew.cooper3@citrix.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.

Oh I don't care that much, though I would have left as hard coded numbers.

Did I give an Ack yet? Here you can have one:
Acked-by: Keir Fraser <keir@xen.org>

 -- Keir

  reply	other threads:[~2013-09-26 19:13 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
2013-09-26 19:13         ` Keir Fraser [this message]
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=CE6A45DF.3567D%keir.xen@gmail.com \
    --to=keir.xen@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=Paul.Durrant@citrix.com \
    --cc=andrew.cooper3@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).