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