[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] hvmloader/smbios: Change strncpy to memcpy for anchor strings.

>>> On 24.09.13 at 12:11, Keir Fraser <keir.xen@xxxxxxxxx> wrote:
> On 24/09/2013 10:39, "Jan Beulich" <JBeulich@xxxxxxxx> 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.

Yes - I'm fine with both; I don't even favor one over the other.


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.