Received: from eggs.gnu.org ([2001:4830:134:3::10]:56958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VenKc-0007C4-EP for qemu-devel@nongnu.org; Fri, 08 Nov 2013 09:46:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VenKW-0006hT-EK for qemu-devel@nongnu.org; Fri, 08 Nov 2013 09:46:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56211) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VenKW-0006hK-6H for qemu-devel@nongnu.org; Fri, 08 Nov 2013 09:46:36 -0500 Date: Fri, 8 Nov 2013 09:46:27 -0500 From: Jeff Cody Message-ID: <20131108144627.GB19612@localhost.localdomain> References: <1383707361-19580-1-git-send-email-gesaint@linux.vnet.ibm.com> <1383707361-19580-2-git-send-email-gesaint@linux.vnet.ibm.com> <20131108101940.GB26775@T430s.nay.redhat.com> <527CECD7.9020202@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <527CECD7.9020202@redhat.com> Subject: Re: [Qemu-devel] [PATCH V6 1/5] block/qemu-img: Refine and export infinite loop checking in collect_image_info_list() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, wdongxu@linux.vnet.ibm.com, stefanha@gmail.com, qemu-devel@nongnu.org, Xu Wang , famz@redhat.com, Xu Wang , xiawenc@linux.vnet.ibm.com On Fri, Nov 08, 2013 at 06:53:27AM -0700, Eric Blake wrote: > On 11/08/2013 03:19 AM, Fam Zheng wrote: > > > >> + BlockDriverState *bs; > >> + BlockDriver *drv; > >> + char fbuf[1024]; > > > > Could use PATH_MAX. > > PATH_MAX is undefined on some platforms, and could also be defined to > something larger than a page which could lead to nastiness if you end up > overflowing the stack. I personally prefer malloc'd buffers rather than > attempting to guess at how large to size things, although the rest of > the code base also has similar caps at 1024 so this isn't making it worse. > A quick grep through the code shows ~57 arrays allocated using 1024, and ~63 allocated using PATH_MAX. Clearly not all of the 1024 allocation cases are pathname related, but certainly some of them are. Maybe it makes sense to have a QEMU_PATH_MAX defined to 1024 in qemu, so at least we are consistent everywhere. (To clarify for Xu, I am not talking about this patch series at all, just in general). -Jeff