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

Re: [Xen-devel] [PATCH v3 04/24] xen: guestcopy: Provide an helper to safely copy string from guest



Hi Jan,

On 19/01/15 16:51, Jan Beulich wrote:
>>>> On 13.01.15 at 15:25, <julien.grall@xxxxxxxxxx> wrote:
>> --- /dev/null
>> +++ b/xen/common/guestcopy.c
>> @@ -0,0 +1,30 @@
>> +#include <xen/config.h>
>> +#include <xen/lib.h>
>> +#include <xen/guest_access.h>
>> +#include <xen/err.h>
>> +
>> +/* The function copies a string from the guest and adds a NUL to
>> + * make sure the string is correctly terminated.
>> + */
> 
> Coding style.

Ok.

> 
>> +void *safe_copy_string_from_guest(XEN_GUEST_HANDLE(char) u_buf,
>> +                                  size_t size, size_t max_size)
> 
> Is the "safe_" prefix really meaningful? I.e. is this function more
> safe than e.g. copy_from_guest()?

It's safe in the sense, the function adds a NUL to make sure the strings
is correctly terminated.

On the first v1, you said that name "copy_string_from_guest" doesn't
match the behavior of the generic helper [1]. So which name do you
suggest for this function?

> 
>> +{
>> +    char *tmp;
>> +
>> +    if ( size > max_size )
>> +        return ERR_PTR(-ENOENT);
> 
> -ENOBUFS?

I will use it.

Regards,

[1] http://lists.xen.org/archives/html/xen-devel/2014-06/msg02361.html

-- 
Julien Grall

_______________________________________________
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®.