From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A394C282DC for ; Wed, 22 May 2019 19:25:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 165BF217D9 for ; Wed, 22 May 2019 19:25:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="buz8zzBW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 165BF217D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:50062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWrO-00014e-Aj for qemu-devel@archiver.kernel.org; Wed, 22 May 2019 15:25:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTWOr-0008Ga-9t for qemu-devel@nongnu.org; Wed, 22 May 2019 14:55:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTWCE-00084h-NJ for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:39 -0400 Received: from mail-yw1-xc42.google.com ([2607:f8b0:4864:20::c42]:44705) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTWCE-00084B-3Y for qemu-devel@nongnu.org; Wed, 22 May 2019 14:42:38 -0400 Received: by mail-yw1-xc42.google.com with SMTP id e74so1231751ywe.11 for ; Wed, 22 May 2019 11:42:38 -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=buz8zzBW8+fGmmxjgk6pFxcVeQ8mDCKNmPovFUaM5dBh/03FFMZjutDleauPoWTv/h mXNxnUnWPNz5+cVELkiJIume8PzXHMBxXFzV64XzAbeh/zWa5AIpQZv+g+8lTgsLV/Gi 5Fmb+blYFCyvDeiYLS3DVPGNB+E13l185tUTd+OZec6mij4suQ+JLUp8H84RRmWIDOYm j1Wef8H501WCFHlOyUeb5XQCizrHz/0wphr5Gxvk08qWPKM8dXYsJp9F7MNAm4hBE5iq nouCjgqzMxg6L+5BElqCvwHuvZH12nB0ZWp2IuZS2EyHXJjgKps2e2qCioX7oKoHQBJl 1ejQ== 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=MTXNrx1wqW//qUi7fzgyfPxY/HdlLlSw6Uo3Y9+YRor57Xa1IJ+ASrAqgKcGwD7jAi aM2eMTxKvMLYNHAfeEomhCPFbp6Hr1UcIEQoYUYGrP7EUrOdqYc/U8pKFFRyV0EDmcp0 e5EOaYUMkXJ08HgQCKg+FN+obMNjPcPMdgPwB++aSInujdBOG4w7XSIPxflNqw16Wij4 ehgCFAApDaW2lfMNnutAQabBIV04X3OswIHZoSHLfohQwTWCOrasQUFHYwoWJb8YlqAP knHqQElH5kosnGtQ+RsqLEuMmNTuqAg1X2VHvjKspBmOH5A6kIzfZw+zvPsKLztd7MEd iy/g== X-Gm-Message-State: APjAAAWqi6DvMslHa4By23f0eZNXcElNbJ1m5/cysITlLPFveCglA/Fw NoTMm6PUVZrMOT7K/f/bwv3a2ELxOFk= X-Google-Smtp-Source: APXvYqwualEZ2U5BPuj12JpELI6SlLXLIg4F0ivawGuksAtBsKA38pTHL2Oh3s+5qxKKcDkFIaq3vw== X-Received: by 2002:a0d:e584:: with SMTP id o126mr25630935ywe.81.1558550557014; Wed, 22 May 2019 11:42:37 -0700 (PDT) Received: from localhost.localdomain ([71.46.56.17]) by smtp.gmail.com with ESMTPSA id 206sm1299445ywq.74.2019.05.22.11.42.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 11:42:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 22 May 2019 14:42:09 -0400 Message-Id: <20190522184226.17871-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190522184226.17871-1-richard.henderson@linaro.org> References: <20190522184226.17871-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c42 Subject: [Qemu-devel] [PULL 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.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(-) 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; -- 2.17.1