From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>, Wei Liu <wei.liu2@citrix.com>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 1/2] hvmloader: correctly copy signature to info structures
Date: Fri, 19 Aug 2016 10:42:32 +0100 [thread overview]
Message-ID: <43a9210b-a6a2-43d9-361b-cd4fd0fd45f4@citrix.com> (raw)
In-Reply-To: <57B6DE8A02000078001074D9@prv-mh.provo.novell.com>
On 19/08/16 09:25, Jan Beulich wrote:
>>>> On 19.08.16 at 10:06, <wei.liu2@citrix.com> wrote:
>> --- a/tools/firmware/hvmloader/ovmf.c
>> +++ b/tools/firmware/hvmloader/ovmf.c
>> @@ -67,10 +67,11 @@ struct ovmf_info {
>> static void ovmf_setup_bios_info(void)
>> {
>> struct ovmf_info *info = (void *)OVMF_INFO_PHYSICAL_ADDRESS;
>> + const char sig[] = "XenHVMOVMF";
>>
>> memset(info, 0, sizeof(*info));
>>
>> - memcpy(info->signature, "XenHVMOVMF", sizeof(info->signature));
>> + memcpy(info->signature, sig, sizeof(sig));
>> info->length = sizeof(*info);
>> }
> I think using strncpy() would be more natural in cases like this,
> as it would at once make clear that the destination can't be
> overrun no matter how large the string literal.
How about structure assignment?
*info = (struct ovmf_info) { .signature = "XenHVMOVMF", .length =
sizeof(*info) }
which also subsumed the memset()?
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-19 9:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-19 8:06 [PATCH 0/2] hvmloader: fix two issues spotted by Coverity Wei Liu
2016-08-19 8:06 ` [PATCH 1/2] hvmloader: correctly copy signature to info structures Wei Liu
2016-08-19 8:25 ` Jan Beulich
2016-08-19 9:42 ` Andrew Cooper [this message]
2016-08-19 11:58 ` Jan Beulich
2016-08-19 8:06 ` [PATCH 2/2] hvmloader: cast to 64bit before multiplication in get_module_entry Wei Liu
2016-08-19 8:31 ` Jan Beulich
2016-08-19 10:09 ` Andrew Cooper
2016-08-19 12:00 ` Jan Beulich
2016-08-22 11:37 ` Wei Liu
2016-08-22 11:55 ` 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=43a9210b-a6a2-43d9-361b-cd4fd0fd45f4@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=anthony.perard@citrix.com \
--cc=wei.liu2@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 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.