From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=41796 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0bjV-0001NC-7s for qemu-devel@nongnu.org; Tue, 28 Sep 2010 11:04:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0bii-0006CU-TH for qemu-devel@nongnu.org; Tue, 28 Sep 2010 11:03:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28718) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0bii-0006CI-NB for qemu-devel@nongnu.org; Tue, 28 Sep 2010 11:03:52 -0400 Date: Tue, 28 Sep 2010 16:57:44 +0200 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] [PATCH] monitor: properly handle invalid fd/vhostfd from command line Message-ID: <20100928145743.GC15294@redhat.com> References: <20100927075244.8835.530.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> <20100928115343.78357291@doriath> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100928115343.78357291@doriath> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: Jason Wang , qemu-devel@nongnu.org On Tue, Sep 28, 2010 at 11:53:43AM -0300, Luiz Capitulino wrote: > On Mon, 27 Sep 2010 15:52:44 +0800 > Jason Wang wrote: > > > monitor_get_fd() may also be used to parse fd or vhostfd from command line, so > > we need to check whether the pointer of mon is NULL to avoid segmentation fault > > when user pass invalid name of fd or vhostfd. > > Invalid fdname is handled just fine, I have the impression this patch fixes > something else. > > Could you elaborate on the real problem here and/or show to reproduce? Try pasing fd= (no value) as a parameter, and see what happens. > > Signed-off-by: Jason Wang > > --- > > monitor.c | 4 ++++ > > 1 files changed, 4 insertions(+), 0 deletions(-) > > > > diff --git a/monitor.c b/monitor.c > > index e602480..5bb4ff0 100644 > > --- a/monitor.c > > +++ b/monitor.c > > @@ -2345,6 +2345,10 @@ int monitor_get_fd(Monitor *mon, const char *fdname) > > { > > mon_fd_t *monfd; > > > > + if (mon == NULL) { > > + return -1; > > + } > > + > > QLIST_FOREACH(monfd, &mon->fds, next) { > > int fd; > > > > > >