From: Ian Jackson Subject: Re: [PATCH] libxl: fix cd insert/eject Date: Thu, 17 Feb 2011 19:10:59 +0000 Message-ID: <19805.29379.278449.777667@mariner.uk.xensource.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Stefano Stabellini writes ("[Xen-devel] [PATCH] libxl: fix cd insert/eject"): > + char backend_type[5]; ... > + sscanf(backend, "/local/domain/%d/backend/%5[a-z]/%*d/%*d", &disk->backend_domid, backend_type); >From sscanf(3): s Matches a sequence of non-white-space characters; the next pointer must be a pointer to character array that is long enough to hold the input sequence and the terminating null character ('\0'), which is added automatically. The input string stops at white space or at the maximum field width, whichever occurs first. So I think your buffer has an off-by-one error in its size. Also you should not duplicate a magic number like that. Use a #define and preprocessor stringification. Ian.