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: 1056826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jZD3vM5M"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44LBTy4gP4z9s4Y for ; Fri, 15 Mar 2019 14:52:06 +1100 (AEDT) Received: from localhost ([127.0.0.1]:49018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4dt6-000219-GZ for incoming@patchwork.ozlabs.org; Thu, 14 Mar 2019 23:52:04 -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-Google-Smtp-Source: APXvYqzzXTxiXSfqi9hpr/k+qzBneWs/zHsnlytRv7gXUB/GNC2N+q3J9BtzZfCusPK6dKmLD3I2sA== 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+incoming=patchwork.ozlabs.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 Reviewed-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé --- ui/vnc.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) 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;