From patchwork Mon May 6 17:33:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163426 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp258369ilm; Mon, 6 May 2019 10:40:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBAhHDFlNzqAeTTrMv4u4sa2FP4ATu3UanlgDwaxc3P2940tFHui/Z3B0AsWzEd+u2CLOL X-Received: by 2002:adf:f508:: with SMTP id q8mr796074wro.225.1557164429832; Mon, 06 May 2019 10:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557164429; cv=none; d=google.com; s=arc-20160816; b=rHR6S2P38Se05a6w3ZvXkMCVBeECpeyLjtYgzS9U627Nounyw/IxZ7MjaHckoIzl1S 0TJmdZbtmJLNLowcYRV/T1sfgjbW8LQTv70yxlcNGWMzYX0DTKDuxzot7UD7G6ylzl5F Z3wxX+8fVARpPJv3/ufE4sukhoWjarj7NcH2Q7mndzerb60BwWkHFXnfwuSmng6Zcj7r hDcmotqJsFNTIT04SF2yUJORA5FvEMDGZQR20V98Lkk7bCv4djhveA+xi3pKPMXJUnN9 5skX+/LZNjETUzGOCKBs2KpAj1dHGLm+ni9Nf6XTJkrReucERM7d5VddkdNa9Pke+sg4 lbBA== 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=jYAIQMfujH1Yj8GqMNdb9ZgzR2B+8AW7wjG3BA673NY=; b=O3807r+sPTbDtUTqPBoIB2SPWEa4H2oLWbgA5IWwP3ENWZkBeJhssBNuSnz8XOFHDt KPqV0ucovIqfzfNWrsJXUCGiwsb95DSkaes5gtrH/7gNwDwxjfWERAYx4N5cheHMK7ac K6CbijAG9H8no0Nr11OgTchU5QdPEFAJDH2Yfo0EaAbBMwaJ3jIoKt4uf7uS5bB+vqOz UEu3Wf37dh8fGIp9HGnm3/jkjyHRhijKHzCDANDFGDhGUNa5iWj3CuVulckucec8deSw tY/McSMQB2wz/PCCy002+Ikkgs2pzHLDNDaYpV6tapQGvkYsLdTbm5vFX9ucX/NC8Kxd sRCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mLk6dAg1; 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 x5si487603wrl.368.2019.05.06.10.40.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 06 May 2019 10:40:29 -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=mLk6dAg1; 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]:59971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNhbI-0006gR-MA for patch@linaro.org; Mon, 06 May 2019 13:40:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNhVB-00012t-5m for qemu-devel@nongnu.org; Mon, 06 May 2019 13:34:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNhVA-0001Jj-3J for qemu-devel@nongnu.org; Mon, 06 May 2019 13:34:09 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:33275) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hNhV9-0001Hu-C3 for qemu-devel@nongnu.org; Mon, 06 May 2019 13:34:07 -0400 Received: by mail-pf1-x444.google.com with SMTP id z28so7145546pfk.0 for ; Mon, 06 May 2019 10:34:07 -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=jYAIQMfujH1Yj8GqMNdb9ZgzR2B+8AW7wjG3BA673NY=; b=mLk6dAg1QsjNbOm4DQ60Gu/71PfAo5s0UVcwGKOTIgmRy1yEjAWDGZj+ixu4KPy0LV wyk29yKHH9c2inXYUpr1O/VdFBEKgC3fNmFRchbiYAGm2sxwRkUWW7IyoJqfHObtjbxr pXTa4TmOykFdfDb8tU/evt1Bx3m3YiddcZu2uKeZTj2HMRCR8FADxOEq4p4fsdeewNS1 2T5Fx+hnst+1TYvyT5NNBFUpqu/QcXRCPmtnNw8tbmvLaK5Ennp2Xs5xxMTMyW3TeotE xOrjEW55mv+bAQaw4Ar93r+DmotWmAQwULfyizrE4YQIWz5TQXQuk4pUcmCcc5SD7cx9 etcw== 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=jYAIQMfujH1Yj8GqMNdb9ZgzR2B+8AW7wjG3BA673NY=; b=bNgl0Egww3oOTKM/KhzhxYObZi5FGTRmrcmmIS4wsfje/x4GJRB05IlyBNXsbCxLCn kVHQcNHtdvFsFGoKB4U6rRPIDF1V0HlXw4Kl/H1M93QDEVnlHOXVLsYi7NCcSKlcekHg dkQ0rAbQstf8TJKrQVWnWHzSO9grD5W/wbeM/ojKMId+eqyDt8N2POjzBPYlYx4plyQA jcTOLtsv+WGSY1EeoAMY0zlw8tJ0Phe5nn7DKcIGJKgfmkROz9FSooXUgrF/VXZSTKXx vryyw4BjdBdq2t9aV4g7umXYizUb53VX92bnlHFRJcQi6Em262iqtSBrNzLVTsD8hHgA skzw== X-Gm-Message-State: APjAAAVZKlSfzClSECsQcK6krDrweLvZQpFNPrR5v9a73l3h9QVJCp3k 6HlpYPNxei3rz0lgwdwmhN1tPgufPiQ= X-Received: by 2002:a62:1b8a:: with SMTP id b132mr34709412pfb.19.1557164045886; Mon, 06 May 2019 10:34:05 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id k9sm2268839pfa.180.2019.05.06.10.34.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 10:34:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 6 May 2019 10:33:37 -0700 Message-Id: <20190506173353.32206-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190506173353.32206-1-richard.henderson@linaro.org> References: <20190506173353.32206-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::444 Subject: [Qemu-devel] [PATCH v4 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: 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 Reviewed-by: Laurent Vivier 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;