[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V6 1/5] block/qemu-img: Refine and export infini
From: |
Jeff Cody |
Subject: |
Re: [Qemu-devel] [PATCH V6 1/5] block/qemu-img: Refine and export infinite loop checking in collect_image_info_list() |
Date: |
Fri, 8 Nov 2013 09:46:27 -0500 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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
- [Qemu-devel] [PATCH V6 0/5] Refine and export backing file loop check, Xu Wang, 2013/11/05
- [Qemu-devel] [PATCH V6 2/5] qemu-img: Add infinite loop checking in bdrv_new_open(), Xu Wang, 2013/11/05
- [Qemu-devel] [PATCH V6 3/5] block: Add check infinite loop in bdrv_img_create(), Xu Wang, 2013/11/05
- [Qemu-devel] [PATCH V6 4/5] block: Add backing file loop check in change_backing_file(), Xu Wang, 2013/11/05
- [Qemu-devel] [PATCH V6 5/5] blockdev: Add infinite loop check in drive_init(), Xu Wang, 2013/11/05