From patchwork Fri Mar 15 03:26:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160389 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp16274350jad; Thu, 14 Mar 2019 20:51:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJN0Gcx4RqZ3G/hoa63y4BfnGNb3mMvZJnH5wWz7filvrcRloAT+/6UDjVmZ2uC8hU5zn/ X-Received: by 2002:a1c:7a07:: with SMTP id v7mr532243wmc.30.1552621896875; Thu, 14 Mar 2019 20:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552621896; cv=none; d=google.com; s=arc-20160816; b=PD9iyNw0FboBxz762Ba3rNf0jqg+AzyO+m+Rbmbemu06n1k72d2LHaP8Jq8ScuISWP HfdBHR4qlG2JIAVTkcfM5o+4L0YjYUPLqN3VSAK9DwGFu71EkL/8h2XqN16V5ajxnEj9 NJAIpBWmkwd3ykEWzKrGn0vJTREwzYdbY+0HuVK4aTpbaB1mmWW2GSP0w7yyt5j8e+Nt WQnvZ8jYU6llFzaP0uxFCmgj4wu1YN24fb8U4tnecmr5IgGnjCB0SY4/0X8/RSTFUR2u 4+tcwT54Sqq6oJAwQrPCQLzHR8FccwjRhPlGmIWDY5LoieJWelNRT9++yPG8yA7moBkG o57A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=4poveDpJ7DPmdIGwLj/FIj6SSKHQVllEi0VHCsLFyB0=; b=vCpmy7uNyy/LBR+EfOqHGd0H2G8bT8cWUxN7/znyKxaDx0Kl1d6dprow6TpthP+2p+ QREoOHk20DzBi4oqlmaaGm4hCzrxKGgREV4XjOpWDgZZRf2WwvKtl1av9oI9zq6gDRpJ AFpG6pOT7Ko1e3sJE3z3wITOgiEYK25K1XZRgmGemLUeomARpuZrNS8wi8NoSTmPbcx4 +60+nQImEtJ1GmyGYVTTimGrzdsQL6wtSBrJrTj+GEZ5vDyvgJ5gYfAtGSQqh+eyayqq bbsr7hw3+5tMwuBrWF/hrbKkk/BV0WqEFx5R5O4zWuu/Ty+PmRubVeSRVORqnWMWdlmt JZKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jZD3vM5M; 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 u20si390826wmc.109.2019.03.14.20.51.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 14 Mar 2019 20:51:36 -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=jZD3vM5M; 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]:49018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4dsd-000219-Qb for patch@linaro.org; Thu, 14 Mar 2019 23:51:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4dcL-0005BE-AU for qemu-devel@nongnu.org; Thu, 14 Mar 2019 23:34:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4dUY-0002px-EH for qemu-devel@nongnu.org; Thu, 14 Mar 2019 23:26:43 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:46981) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h4dUY-0002pE-62 for qemu-devel@nongnu.org; Thu, 14 Mar 2019 23:26:42 -0400 Received: by mail-pg1-x52e.google.com with SMTP id a22so5378817pgg.13 for ; Thu, 14 Mar 2019 20:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4poveDpJ7DPmdIGwLj/FIj6SSKHQVllEi0VHCsLFyB0=; b=jZD3vM5MAYHGm3lPyVaw08kpidCfwemSPDesTSQ2Pm0NteM5Usq5lbwgNC6lIeC4Hj PoHpuq/j4CUMobL1ZYF3I0ZK6OA93vK+jaKSU0Aa3+vykTj5WrMnt1e6KVQxE1qKrWpS x9X0hxzMl8+UY6fzR0CF4wX+2Z4Td4dQ8eE4b/DiBP3V5DpuNAV48aTmZechMtJCeR0b ZJ98LV3GTnQIcgtV27JeSuX00XgYUTrB3qoCCt+uvS5KKNsVFaGpzfCO7Sc7F56qIyAa FNVqaDOk6OpCPph6LOwQCRYDxULMkcJjzPgy7iC3JlvD5dgoJwaZNDJa0vP9C7/P3gg9 6O9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4poveDpJ7DPmdIGwLj/FIj6SSKHQVllEi0VHCsLFyB0=; b=lsB70ipXKhB3C8ofWlpemKusRixULETVzO/+V1E1spZYISuGiX4e+vicv8cZm0BxEl iqt9Zy9/lzdXZCWFw2EDYmcxmtps3XMXmDTsiqqEmXI564VKwxinnxJj5OU+s1U//8FD raPEVM4+qGpbngMYi620OVoKIVviRsUrstMN2/9PYVJC4So6ZbZFr1EG+tFy5kOGi2Kt 0Q7VTX/+6aRjApUhOPsFqc8QZfsNlVQxMedixh41sClCN9HE34vl+WO3Zs2KbdBCZPMd jjMrHLUNLpJXJrmJqpkzOUw0n4sK/aMq2Ts0G+VRcFYWa8hbWFaKrTteXXvHtnmJlnPT aeWw== X-Gm-Message-State: APjAAAUtPNlVFqwXLu5v+z6uCS9OxW4j4Wsf9HLwIVpa13yKf3UDX2oV c4b2Dtt6XyDs7MKS9GRE2c3UkkWNfzI= X-Received: by 2002:a62:57d7:: with SMTP id i84mr1720295pfj.125.1552620400869; Thu, 14 Mar 2019 20:26:40 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id d26sm690816pfn.86.2019.03.14.20.26.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Mar 2019 20:26:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 14 Mar 2019 20:26:13 -0700 Message-Id: <20190315032629.21234-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190315032629.21234-1-richard.henderson@linaro.org> References: <20190315032629.21234-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52e Subject: [Qemu-devel] [PATCH v3 07/23] ui/vnc: Split out authentication_failure 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: , Cc: Gerd Hoffmann 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. Cc: Gerd Hoffmann Signed-off-by: Richard Henderson --- ui/vnc.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) -- 2.17.2 Reviewed-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé 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;