From: "Jan Beulich" Subject: Re: [PATCH v2 02/21] xen: guestcopy: Provide an helper to safely copy string from guest Date: Fri, 01 Aug 2014 09:40:30 +0100 Message-ID: <53DB6E9E02000078000284F9@mail.emea.novell.com> References: <1406818852-31856-1-git-send-email-julien.grall@linaro.org> <1406818852-31856-3-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XD8O6-0003YK-Sw for xen-devel@lists.xenproject.org; Fri, 01 Aug 2014 08:40:30 +0000 In-Reply-To: <1406818852-31856-3-git-send-email-julien.grall@linaro.org> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: Keir Fraser , ian.campbell@citrix.com, tim@xen.org, Ian Jackson , stefano.stabellini@citrix.com, xen-devel@lists.xenproject.org, Daniel De Graaf List-Id: xen-devel@lists.xenproject.org >>> On 31.07.14 at 17:00, wrote: > --- /dev/null > +++ b/xen/common/guestcopy.c > @@ -0,0 +1,29 @@ > +#include > +#include > +#include > + > +/* The function copies a string from the guest and add a NUL-terminated to > + * make sure the string is correctly finished. */ "... and adds a NUL-terminator ...". Also not sure about "finished" here. And please fix the comment style. > +int safe_copy_string_from_guest(XEN_GUEST_HANDLE(char) u_buf, char **buf, > + unsigned long size, unsigned long max_size) size_t please. Further I think this function would benefit from using the definitions in xen/err.h, eliminating the need to return the buffer pointer via indirection. Jan