From: Ian Jackson Subject: Re: [PATCH] qemu-xen: fix segfault with empty cdroms Date: Fri, 11 Feb 2011 17:45:17 +0000 Message-ID: <19797.30125.552075.628420@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] qemu-xen: fix segfault with empty cdroms"): > When the cdrom is empty the params node in xenstore might be missing > completely, cope with it instead of segfaulting. ... > blkdev->params = xenstore_read_be_str(&blkdev->xendev, "params"); > - h = strchr(blkdev->params, ':'); > + if (blkdev->params != NULL) > + h = strchr(blkdev->params, ':'); So blkdev->params may be 0. In that case, we end up with: blkdev->fileproto = ""; blkdev->filename = blkdev->params; so now ->filename may be 0. Eventually, if (bdrv_open2(blkdev->bs, blkdev->filename, qflags, bdrv_find_format(blkdev->fileproto)) != 0) { Isn't that going to crash ? Perhaps a clause needs to be added to: /* do we have all we need? */ if (blkdev->params == NULL || blkdev->mode == NULL || blkdev->type == NULL || blkdev->dev == NULL) return -1; Ian.