From: Wei Liu Subject: Re: [PATCH] tools: libxl: do not overrun input buffer in libxl__parse_mac Date: Thu, 6 Nov 2014 14:55:39 +0000 Message-ID: <20141106145539.GB2580@zion.uk.xensource.com> References: <1415282383-26594-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1415282383-26594-1-git-send-email-ian.campbell@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, Nov 06, 2014 at 01:59:43PM +0000, Ian Campbell wrote: > Valgrind reports: > ==7971== Invalid read of size 1 > ==7971== at 0x40877BE: libxl__parse_mac (libxl_internal.c:288) > ==7971== by 0x405C5F8: libxl__device_nic_from_xs_be (libxl.c:3405) > ==7971== by 0x4065542: libxl__append_nic_list_of_type (libxl.c:3484) > ==7971== by 0x4065542: libxl_device_nic_list (libxl.c:3504) > ==7971== by 0x406F561: libxl_retrieve_domain_configuration (libxl.c:6661) > ==7971== by 0x805671C: reload_domain_config (xl_cmdimpl.c:2037) > ==7971== by 0x8057F30: handle_domain_death (xl_cmdimpl.c:2116) > ==7971== by 0x8057F30: create_domain (xl_cmdimpl.c:2580) > ==7971== by 0x805B4B2: main_create (xl_cmdimpl.c:4652) > ==7971== by 0x804EAB2: main (xl.c:378) > > This is because on the final iteration the tok += 3 skips over the terminating > NUL to the next byte, and then *tok reads it. Fix this by using endptr as the > iterator. > > Signed-off-by: Ian Campbell Acked-by: Wei Liu This is a candidate for backporting. Wei.