From patchwork Fri May 17 02:39:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164358 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1601838ili; Thu, 16 May 2019 19:43:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwucn1dcWbW+5Ns3BYSdwyQ0BFUE9fB8so89qhtN/Z64mxnt+Vcx81AsxGX7SDCCYMYMz8x X-Received: by 2002:a50:f5d9:: with SMTP id x25mr52288586edm.128.1558061026177; Thu, 16 May 2019 19:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558061026; cv=none; d=google.com; s=arc-20160816; b=JS02aLPKQZey9WVml+yKBrqXzRB3J5BT9LJya8Z1Uge43XchVDEK1jTwWIkNS+PfdX PW5TLbSDSmDUOkukwOIfE1sv5+qnB7S/Cm7+iEBBpctA7qX/q48U0iKeFSdhJv2Ml0lg 5SpJuYPi+/rNHRzMsCsVUivQ1XFL/F6zeWphPwtFQ1z5yVTEYQgRJAkjnJI2V1jm/xn4 qdF3aFVqrt+NRuf41QhVq7DOzKCRzfe+tW3a9yVK201o+DijxCPodTwY/eUSiF4AFYLj tgGEPtspSbaISj9fz+ffOWnmViZQrXZ7VFLs/whElPPW8B06wLzwZPm1I5r+BxQKmfbD vsrQ== 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=F4y+F6eS0v2lcLbLQPTfp7QxOAOxAf3KjA8PQD5wJHBWhmZm9jZaD7Vcj5ZOIUaOPo a7cKZ8oho5gU2jjJRT4fOlZ6y2Sk+73diJYawLUL+iAFN3akuPMeHj37TKwgLWaXvfJ0 4zUIMIiLFzyt8cw+gCbEXHXL6CYcBn7nbBGNQeSusk84ggnQcfn6iwC2vYXPR1TYlIKq 1+E3bmAsDNJZqavU7aqbFZkP9EtK88poJxIq9WORtGkRkzsQvjkep+H/sNGC0MIq9xyS fvezz8ND1pAs6MG1vyOjuYk92dCaNJm59X2suF+p88sD38sSQS2Qc3UhqZrDI6z+JvCO pNVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LNPYJC1W; 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 e15si4716637eja.174.2019.05.16.19.43.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 16 May 2019 19:43:46 -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=LNPYJC1W; 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]:40142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRSqX-0000ku-47 for patch@linaro.org; Thu, 16 May 2019 22:43:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRSmZ-0005St-QZ for qemu-devel@nongnu.org; Thu, 16 May 2019 22:39:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRSmY-00025N-CW for qemu-devel@nongnu.org; Thu, 16 May 2019 22:39:39 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:46384) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRSmX-00024V-Ud for qemu-devel@nongnu.org; Thu, 16 May 2019 22:39:38 -0400 Received: by mail-pf1-x442.google.com with SMTP id y11so2853220pfm.13 for ; Thu, 16 May 2019 19:39:37 -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=LNPYJC1WFR6MQja4ezKyO4owmXx5YniGlxytJ//9rjheof42E2cpxfWTIESjIU3eJS GaSPBNYpduTenfusO+TS2lBPEogA+CQPKBhivr7e1MDWYpto7CvGQZGK2dy9mhuQPhCa eH42l0++hbocTw3sJ0HrAx4KVDpZyYE742mThefm0QJ88nxq1kUXnBYDmTxFgDT5At79 FSCklWeEvnFHRPV7LwZ6z2sR0R9+cG5KpS2pWueaqhQUGzOHXzQP7Bq0XTK9/GCuzecG 4RvJMcjrjU8dsBpFwaigX/V8vXokcH0SotoUNVlq4Lad6zCsyy8EFXV/AsPqFj1S5CzE +IPA== 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=BVnqaHc1E3WsRK5875AwUd7BTFx6+zU1PneAKPjIYkMNSYM7zaIf/l3QWk9haEriTG 5050WPqYAQT/oE3bRCIbg0xjSMWA3T7vHNBZecZmYY8pv/6QiiiFFiOiBIzZ3YvjfulJ vaCm7hErizP+gNfZrFrZxktpofsvaXr4n4MILT+sbc/dX04d6suPdAdtQ2cTypZ0Pd0j p0LalFY3jQDYnO88avoMexSEGEmYSfBgABFuwj+85iOCQweq1bJIuXczp5abOdDh2KL/ Z9kZsLsYvgPNNXFDMN1O79F8lOGAV6yTtvzt0QNA+LBMsT2B5yocl2Cp40ehDtU042V7 y3MA== X-Gm-Message-State: APjAAAVRXRENFByvOi0qG/jZR62Vx4Ne8Q5K20Byfl0F2EADZVaeAD27 tLaGvKsf7zRu/NZfr54mlQIPLqjJJl4= X-Received: by 2002:a63:7d18:: with SMTP id y24mr39575186pgc.101.1558060776811; Thu, 16 May 2019 19:39:36 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id w6sm6984152pge.30.2019.05.16.19.39.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 19:39:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 16 May 2019 19:39:07 -0700 Message-Id: <20190517023924.1686-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190517023924.1686-1-richard.henderson@linaro.org> References: <20190517023924.1686-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::442 Subject: [Qemu-devel] [PATCH v8 08/25] 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;