Re: [Qemu-devel] [PATCH 5/8] usb: fix unbounded stack for inotify_watchfn

2016-03-08 Thread Peter Xu
On Tue, Mar 08, 2016 at 01:22:19PM +0100, Paolo Bonzini wrote: > > for (;;) { > > -bytes = read(s->inotifyfd, buf, len); > > +bytes = read(s->inotifyfd, buf, __BUF_LEN); > > Again, here you can use ARRAY_SIZE(buf) and avoid the macro. Yes, will fix. Thanks! Peter

Re: [Qemu-devel] [PATCH 5/8] usb: fix unbounded stack for inotify_watchfn

2016-03-08 Thread Peter Xu
On Tue, Mar 08, 2016 at 01:22:46PM +0100, Paolo Bonzini wrote: > > > On 08/03/2016 08:20, Peter Maydell wrote: > >> > +#define __BUF_LEN (sizeof(struct inotify_event) + NAME_MAX + 1) > >> > /* From the man page: atleast one event can be read */ > >> > -int len = sizeof(struct inotify_eve

Re: [Qemu-devel] [PATCH 5/8] usb: fix unbounded stack for inotify_watchfn

2016-03-08 Thread Paolo Bonzini
On 08/03/2016 08:00, Peter Xu wrote: > Suggested-by: Paolo Bonzini > CC: Gerd Hoffmann > Signed-off-by: Peter Xu > --- > hw/usb/dev-mtp.c | 7 --- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c > index 7391783..e6dae2f 100644 > ---

Re: [Qemu-devel] [PATCH 5/8] usb: fix unbounded stack for inotify_watchfn

2016-03-08 Thread Paolo Bonzini
On 08/03/2016 08:20, Peter Maydell wrote: >> > +#define __BUF_LEN (sizeof(struct inotify_event) + NAME_MAX + 1) >> > /* From the man page: atleast one event can be read */ >> > -int len = sizeof(struct inotify_event) + NAME_MAX + 1; >> > int pos; >> > -char buf[len]; >> > +c

Re: [Qemu-devel] [PATCH 5/8] usb: fix unbounded stack for inotify_watchfn

2016-03-07 Thread Peter Maydell
On 8 March 2016 at 14:00, Peter Xu wrote: > Suggested-by: Paolo Bonzini > CC: Gerd Hoffmann > Signed-off-by: Peter Xu > --- > hw/usb/dev-mtp.c | 7 --- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c > index 7391783..e6dae2f 100644 > -

[Qemu-devel] [PATCH 5/8] usb: fix unbounded stack for inotify_watchfn

2016-03-07 Thread Peter Xu
Suggested-by: Paolo Bonzini CC: Gerd Hoffmann Signed-off-by: Peter Xu --- hw/usb/dev-mtp.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 7391783..e6dae2f 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -432,13 +432,1