From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVyyv-0000GJ-2a for qemu-devel@nongnu.org; Thu, 12 Mar 2015 05:00:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVyyt-00057i-RO for qemu-devel@nongnu.org; Thu, 12 Mar 2015 05:00:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVyyt-00057a-KF for qemu-devel@nongnu.org; Thu, 12 Mar 2015 05:00:39 -0400 From: Gerd Hoffmann Date: Thu, 12 Mar 2015 10:00:25 +0100 Message-Id: <1426150825-782-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1426150825-782-1-git-send-email-kraxel@redhat.com> References: <1426150825-782-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 7/7] vnc: fix segmentation fault when invalid vnc parameters are specified List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gonglei , Gerd Hoffmann , Anthony Liguori From: Gonglei Reproducer: #./qemu-system-x86_64 -vnc :0,ip qemu-system-x86_64: -vnc :1,ip: Invalid parameter 'ip' Segmentation fault (core dumped) Signed-off-by: Gonglei Signed-off-by: Gerd Hoffmann --- ui/vnc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/vnc.c b/ui/vnc.c index 1e95445..6f9b718 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3703,8 +3703,13 @@ QemuOpts *vnc_parse_func(const char *str) { QemuOptsList *olist = qemu_find_opts("vnc"); QemuOpts *opts = qemu_opts_parse(olist, str, 1); - const char *id = qemu_opts_id(opts); + const char *id; + if (!opts) { + return NULL; + } + + id = qemu_opts_id(opts); if (!id) { /* auto-assign id if not present */ vnc_auto_assign_id(olist, opts); -- 1.8.3.1