From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH v2 02/21] xen: guestcopy: Provide an helper to safely copy string from guest Date: Wed, 06 Aug 2014 15:22:25 +0100 Message-ID: <53E23A21.1000909@linaro.org> 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.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XF26p-0002NJ-NV for xen-devel@lists.xenproject.org; Wed, 06 Aug 2014 14:22:31 +0000 Received: by mail-wg0-f52.google.com with SMTP id a1so2659021wgh.11 for ; Wed, 06 Aug 2014 07:22:30 -0700 (PDT) In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: Keir Fraser , ian.campbell@citrix.com, tim@xen.org, Ian Jackson , stefano.stabellini@citrix.com, Jan Beulich , xen-devel@lists.xenproject.org, Daniel De Graaf List-Id: xen-devel@lists.xenproject.org Hi Stefano, On 08/06/2014 02:56 PM, Stefano Stabellini wrote: >> diff --git a/xen/common/guestcopy.c b/xen/common/guestcopy.c >> new file mode 100644 >> index 0000000..c01555c >> --- /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. */ >> +int safe_copy_string_from_guest(XEN_GUEST_HANDLE(char) u_buf, char **buf, >> + unsigned long size, unsigned long max_size) > > Why did you change the size type from size_t to unsigned long? I don't remember why. I will reuse size_t here. Regards, -- Julien Grall