From: "Jan Beulich" Subject: Re: [PATCH v3 04/24] xen: guestcopy: Provide an helper to safely copy string from guest Date: Mon, 19 Jan 2015 16:51:36 +0000 Message-ID: <54BD44280200007800056A49@mail.emea.novell.com> References: <1421159133-31526-1-git-send-email-julien.grall@linaro.org> <1421159133-31526-5-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.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YDFYC-0001RK-CD for xen-devel@lists.xenproject.org; Mon, 19 Jan 2015 16:51:40 +0000 In-Reply-To: <1421159133-31526-5-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 13.01.15 at 15:25, wrote: > --- /dev/null > +++ b/xen/common/guestcopy.c > @@ -0,0 +1,30 @@ > +#include > +#include > +#include > +#include > + > +/* The function copies a string from the guest and adds a NUL to > + * make sure the string is correctly terminated. > + */ Coding style. > +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()? > +{ > + char *tmp; > + > + if ( size > max_size ) > + return ERR_PTR(-ENOENT); -ENOBUFS? Jan