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

 -- Keir



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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