From patchwork Fri May 10 01:24:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163803 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp1729470ilr; Thu, 9 May 2019 18:37:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBOBJV8nK8jvHefKLAyP9BE9OL6GFMAnetegD7U2lE9uN8zlJxUXut/BHYWSc3x1JtawCF X-Received: by 2002:a5d:468b:: with SMTP id u11mr5571783wrq.276.1557452262982; Thu, 09 May 2019 18:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557452262; cv=none; d=google.com; s=arc-20160816; b=xl5ATCn0wZq+c5j+mrhCYK9s0zAtagxjeBksiwe6Qj4F5xnl9u8JK9paZYWXt/l5qJ eUmEXMOc5fbgVa/yxcuLIwuXQXx9J7Gis5YZWkqpFqDcq0OSTliuI0xKuBBgsL2zfNJq JhhOvJ16UFesDCsLRuJq8jF/ZVPfDKWeqNn5sHO0U5Riz6rsGpNdDqT7ZIPNMW3608KA 0e6XEna0BRCw9usrblNAbLKnGIUgMxQbN7XktKopJRedgAai8ZkIbQ/pRTALx8wSzWw/ K60a58kF8n8rDB3T0ixzgIREMbcxIbT5L8/P/ILQUjB5aEdu6P0QkctSxsWcXI+ewiJ7 y3EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=zQEKMjfpCTDyJlIECnLYp610ugeuDB8/XWCLVFEbpkI=; b=mUSJvJBQepGoaxcAJql9Fe2suDSxN+ty8V2hP9XpkCcZQVNbeiqvNjUObG//LApwet McSlZ+qo+i+rC3Ka5IbesyptwevwUUbJz8EoGqtIvwZo4gKmJpJ7v4bZ/CncTRQTkH1U nQpnvc3QI55Z+35V6NrBERg/Z8kPr2POIeqPErtgaZaVvruXe10RAfs3E4bdr84uCweg 7jdmejJ/1XY3uRCNFusvksw4Mn7mlHFDN1lYqi40XTraUVxOUUro446y7RNPy+qkxjcR aQd9p5/P5aBA9/JF51gIFbAhpb/Ao6kSxFvLXz3IEUjkmXXNOh48b1HpRaH1CDbD+fsB Di0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=y2g1Rits; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h66si2766285wme.128.2019.05.09.18.37.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 May 2019 18:37:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=y2g1Rits; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:35162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOuTm-0000rP-0c for patch@linaro.org; Thu, 09 May 2019 21:37:42 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOuHk-0006Ix-Ra for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOuHj-00014l-GS for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:16 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:46003) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOuHj-000111-78 for qemu-devel@nongnu.org; Thu, 09 May 2019 21:25:15 -0400 Received: by mail-pg1-x541.google.com with SMTP id i21so2107040pgi.12 for ; Thu, 09 May 2019 18:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=zQEKMjfpCTDyJlIECnLYp610ugeuDB8/XWCLVFEbpkI=; b=y2g1Rits7EabH8URhQFjlCxR1PX6UaETo8kTzAGIRREYFBIZkP2TCQ49d1BSYqHqtS aaysfVPPg3je/PAHExurerfrD0QFHLhLpB5eXTX9Bm2gM9o4/0rhrOMlpwRWHmTCbCVy jszUfwcTN7/MIN6guL5HuSMmYSxSX/oC/fNYdq3QtziEZh/nYMRY7F2W2y2JeR2TsPs8 zYz/ePlmNOZsJKzrS9mqlrxW7n6z/p6f0/6Bd1m9Ilezils2ZX4PREW41Yp5zEvdONKx AuNKrd7a8FIbr9aWBXNFnCN3b+uPqj3JVnypRlEFitBS0y1MbfjrtAHcOmklgT2EfW4U fIAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zQEKMjfpCTDyJlIECnLYp610ugeuDB8/XWCLVFEbpkI=; b=GzZ6sdsQnCxaP08WJJVqg6PJeegbCSKeJSjuYCKexO9rjX+Dr5eXHngzl6IAyzwI/V 0o6PIj5z5wF3XNBoPVORTvjuBDC+RD1uQfzz3axtmU7K4vfPIGaVe9++oWayecwAimOI cm4ZuIoM1zH4SIVpwEKm49Qc/1jM4jAlXzyPMnEULV1BHfzT2HBkE4VExzMeAJhGXxPk LJc62QOib5ddwwByZRffPC7xcMYh80tigz+rRAJ2YehoZseQ/8V51NBCub7zPCkgMOEO W4N2VYxXdGeaaP+OZUlesUKTzQLCdVPA+oN/ucBrxIbQ+Ij/7Zu60chlSzmtz1fMv1W8 6Geg== X-Gm-Message-State: APjAAAWz3ujSzbDI1YJdS6ds1Jv2j9jyEYFx8m+7eNSsZdIqLLn0Oesa OaMsp6jBX8jdsifxjaQPmYBM3dW3epE= X-Received: by 2002:aa7:8083:: with SMTP id v3mr10156834pff.135.1557451510326; Thu, 09 May 2019 18:25:10 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id n18sm8252700pfi.48.2019.05.09.18.25.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 18:25:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 18:24:42 -0700 Message-Id: <20190510012458.22706-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510012458.22706-1-richard.henderson@linaro.org> References: <20190510012458.22706-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v5 08/24] ui/vnc: Split out authentication_failed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There were 3 copies of this code, one of which used the wrong data size for the failure indicator. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Signed-off-by: Richard Henderson --- ui/vnc.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/ui/vnc.c b/ui/vnc.c index 1871422e1d..785edf3af1 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2535,6 +2535,18 @@ void start_client_init(VncState *vs) vnc_read_when(vs, protocol_client_init, 1); } +static void authentication_failed(VncState *vs) +{ + vnc_write_u32(vs, 1); /* Reject auth */ + if (vs->minor >= 8) { + static const char err[] = "Authentication failed"; + vnc_write_u32(vs, sizeof(err)); + vnc_write(vs, err, sizeof(err)); + } + vnc_flush(vs); + vnc_client_error(vs); +} + static void make_challenge(VncState *vs) { int i; @@ -2609,14 +2621,7 @@ static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len) return 0; reject: - vnc_write_u32(vs, 1); /* Reject auth */ - if (vs->minor >= 8) { - static const char err[] = "Authentication failed"; - vnc_write_u32(vs, sizeof(err)); - vnc_write(vs, err, sizeof(err)); - } - vnc_flush(vs); - vnc_client_error(vs); + authentication_failed(vs); qcrypto_cipher_free(cipher); return 0; } @@ -2638,13 +2643,7 @@ static int protocol_client_auth(VncState *vs, uint8_t *data, size_t len) * must pick the one we sent. Verify this */ if (data[0] != vs->auth) { /* Reject auth */ trace_vnc_auth_reject(vs, vs->auth, (int)data[0]); - vnc_write_u32(vs, 1); - if (vs->minor >= 8) { - static const char err[] = "Authentication failed"; - vnc_write_u32(vs, sizeof(err)); - vnc_write(vs, err, sizeof(err)); - } - vnc_client_error(vs); + authentication_failed(vs); } else { /* Accept requested auth */ trace_vnc_auth_start(vs, vs->auth); switch (vs->auth) { @@ -2673,13 +2672,7 @@ static int protocol_client_auth(VncState *vs, uint8_t *data, size_t len) default: /* Should not be possible, but just in case */ trace_vnc_auth_fail(vs, vs->auth, "Unhandled auth method", ""); - vnc_write_u8(vs, 1); - if (vs->minor >= 8) { - static const char err[] = "Authentication failed"; - vnc_write_u32(vs, sizeof(err)); - vnc_write(vs, err, sizeof(err)); - } - vnc_client_error(vs); + authentication_failed(vs); } } return 0;