[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 11:11, Keir Fraser 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.
>  -- 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.


Xen-devel mailing list



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