From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QjTyW-0001OX-0f for qemu-devel@nongnu.org; Wed, 20 Jul 2011 06:25:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QjTyS-0004R1-Uw for qemu-devel@nongnu.org; Wed, 20 Jul 2011 06:25:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QjTyS-0004Qg-41 for qemu-devel@nongnu.org; Wed, 20 Jul 2011 06:25:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6KAPpAA018242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Jul 2011 06:25:51 -0400 From: Gerd Hoffmann Date: Wed, 20 Jul 2011 12:25:37 +0200 Message-Id: <1311157538-12753-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1311157538-12753-1-git-send-email-kraxel@redhat.com> References: <1311157538-12753-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] spice: add sanity check for spice ports List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Make sure at least one port (port=.. or tls-port=...) is specified. Also apply range checks to the port numbers. Signed-off-by: Gerd Hoffmann --- ui/spice-core.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/ui/spice-core.c b/ui/spice-core.c index e142452..1100417 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -480,7 +480,16 @@ void qemu_spice_init(void) port = qemu_opt_get_number(opts, "port", 0); tls_port = qemu_opt_get_number(opts, "tls-port", 0); if (!port && !tls_port) { - return; + fprintf(stderr, "neither port nor tls-port specified for spice."); + exit(1); + } + if (port < 0 || port > 65535) { + fprintf(stderr, "spice port is out of range"); + exit(1); + } + if (tls_port < 0 || tls_port > 65535) { + fprintf(stderr, "spice tls-port is out of range"); + exit(1); } password = qemu_opt_get(opts, "password"); -- 1.7.1