From patchwork Tue May 14 19:16:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164236 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3006126ili; Tue, 14 May 2019 12:23:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSKqVSGGh4Td9PHPGnEGhxzNZPEGXypob5U+CuT7DcjcPa2BcQvjLuhBoWiSMq0aTne4Y/ X-Received: by 2002:a50:a3b5:: with SMTP id s50mr38656042edb.149.1557861832709; Tue, 14 May 2019 12:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557861832; cv=none; d=google.com; s=arc-20160816; b=LtISKwjB1qijltCjBWMFPzh0NPbjGIzKHp/Kh0jJwwe0rg+e3LzVpEDziOVqxIirT0 Gq54xKGEZnqOgHAZMuOdGX3wbZ7gjAWiGO6Le9L/SLidgvSC5hAhoR0tGKhgYx0xORuv T4CbOevOqqcbsfvMkJFaCYGd9L4Ij86GtNDwPsdTUwEHLI7glElk/I16WdgtqCQsQ4v1 wurvSQvnXGGNC/JUo9BNX9G0mBExAu5xKSQw2IJMhYeEJJpA6V40PfgU3KgeY7QuaB1f 5/dPQqg4PExA5b8gLlbBHnCAST5BmtnEsBwY8ElOT9Ohuuef8YUeh3su8JyAOjbrtA9h wrwA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=zQEKMjfpCTDyJlIECnLYp610ugeuDB8/XWCLVFEbpkI=; b=Zk9SOp6Pha9nzBaMzMRTSzHK+A64OCZirpm2N3BEuKjAU0ocz8Ihb6eUGx+2/1sgfF 158ixfzk9u2+9C6tJlPTrtDvsyMzuxV7xbgx2jQyGDjj0nSSou9hc5WBxcCUrKk6ay9c i5VbPp/joP3+oHJHVNBAZaINMvV/OWd2NOkzChaCcIDTvBM4zgAES5JLxHpzheClUqih MzurJSVZoyu9fZD5kWeIoF+24m+08xNUPGjygOEQSjukNGQNewMxOkF+DcvuIbCzq7IV 9aGFC1B67JTzX/iE+eofTsl6oHv/+dutlGBWc7oTPKoII1Vuqo38FjqpGipIQpEylYbA bGKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HQN+QVb7; 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 ly1si5964333ejb.146.2019.05.14.12.23.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 14 May 2019 12:23:52 -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=HQN+QVb7; 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]:52990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQd1j-0007oi-H7 for patch@linaro.org; Tue, 14 May 2019 15:23:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQcvD-0002Tp-Ha for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQcvC-0006nN-H2 for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:07 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:38184) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQcvC-0006mI-Av for qemu-devel@nongnu.org; Tue, 14 May 2019 15:17:06 -0400 Received: by mail-pf1-x443.google.com with SMTP id b76so5252pfb.5 for ; Tue, 14 May 2019 12:17:06 -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 :mime-version:content-transfer-encoding; bh=zQEKMjfpCTDyJlIECnLYp610ugeuDB8/XWCLVFEbpkI=; b=HQN+QVb73V3XfZ4T2T+jb1TZWUUTrJtTo3AsjOiBVKA23D71o/rGF4bDpSh9FGB1+X HpEKtIoyEqAcW2rLhJ744tUEAI/6dQGNyUHOSIS8UEUMrXapw4HfdBYld8ohrXI5+NDX uOzLLswjmuGbciMRtFebR9PQRhG+cTPjyGCNjgmJFi+7DudOlSCO+UEIIGsLO0/aT3rZ mwxLXZl7ipPbmh0xy+iwgCRvkwrjLqLgQ193cIbJsE5If8+vV18G1M8zIQzVtkwG5NTH zBj08pw+qPAmE3Z/Z1yKforLWnlTmtvQXkN8tFhEFr6cNC2/AWEVk+eTBoytadFeB8BZ OU5A== 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:mime-version:content-transfer-encoding; bh=zQEKMjfpCTDyJlIECnLYp610ugeuDB8/XWCLVFEbpkI=; b=sWft/Gn+FmuvpMxEMzzzqhw3TVuAybXwXBMqPr7wwJ1ac5qIHmQcPKblvX25rBR2pN jmYy0G9vu9MWMtpYIh+mhOuyvfIiAotjs/JbyWSNkXbEkUnz80JCgVL0mGIT0koEU6X9 L3BkZwu+2H2JDKMAwuFv1kuUBme+g42hHFMX+l7f8jMAU/DpGUZjCJXfZQlVshPTEl87 WFF5PvTc8WwJ7RARoj3HDxkTdfA75MHYbum0AqSAoe6XxbUFY9NKKxdg3j9kre/WRhj4 GOnBiyU64zzfQ6P+2oUvknFQ7yMDL/clyBlunrl9EAKq4QlNTJGySg+jY3GbsAEkRYXk ym6g== X-Gm-Message-State: APjAAAVMN8E//5OAbseF7ifSKIipq40/XqCYCLzlRdSdLClupZX9l4S9 9ewM4CRWcwf93AhVU1Spn4QReVuUJzc= X-Received: by 2002:a63:fa16:: with SMTP id y22mr17448pgh.15.1557861425083; Tue, 14 May 2019 12:17:05 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id o6sm18682982pfa.88.2019.05.14.12.17.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 12:17:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 12:16:36 -0700 Message-Id: <20190514191653.31488-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514191653.31488-1-richard.henderson@linaro.org> References: <20190514191653.31488-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::443 Subject: [Qemu-devel] [PATCH v7 07/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: , Cc: lvivier@redhat.com, berrange@redhat.com, armbru@redhat.com 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;