From patchwork Wed Mar 13 06:26:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160205 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp13956778jad; Tue, 12 Mar 2019 23:35:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxK2WVsuX70mvDHHkntb+cl9h5UpJpLr73EzWSZrcqQHKvnC4ayA+bkE/vWXlaJrhFaMgke X-Received: by 2002:a81:7a04:: with SMTP id v4mr33475691ywc.410.1552458905155; Tue, 12 Mar 2019 23:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552458905; cv=none; d=google.com; s=arc-20160816; b=t1bIqd+lo0OByK6J9gMGzSUkOcJXSy9Th+vumqPMsw2tcnByWTcY3GiRZj7UKdZM/E Q/VDTZzUsnAKylocW95u6YrX9iGYfVi5e4fBVzKY2UHK6W/m8XiF5R9DZtOnNRiW/vsq 6UTJCUQVFaHjaDwnuCAGBzOLhthR8RMj7qHTJMNp/cS4D+FLPUpsE7Fx1zB6ngnyFmje 6DWbibapsjU8K/B8rg8P1AeCejAz+M1oburxltyqyVzTVJbipa7PKI/jDeSPEtsIGYDw oMBhu7UluJKVv3lMQutr9T1fg93MT/IxfMl2D+ACbrUmLwiiHAJoVpxCbRZ8UHU9C9tA oR5w== 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:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=URg26ke8pptD4/rvcTYVkJk/irN25dGRogOZ9l3dOw0=; b=QXjxP6nv9wPytWUMG3N9+5JneavTXG3O8iKFRbp2DIqkaWN0heb+qwuKAaDV1YG8G2 GI4OuwHsjQAYNt7XAHX8213Z3jeXdWe12oA/su6plB8YXhurYma3n2fiMt3wumhRO7Al 8ufA2uHRY8THZVIiOmpEO85+rJ1Ss2BEeDi2uLHq5fGsR22ojEP/e3m9hbaf2VVpJ+dQ 356XRpShvtf9GuPEupQH/INCCnIxu79AvCm3/e/GMJZrCq7IThck6WVXRTwX34OeTttF nS+np23td5fXkN/PWflTx2k8+Fka+L0HvIdcnGQgYA6FH4PzcBibLISlDR4ampsKQzKo AjxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dS3FAoHE; 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 i6si5918994ybk.165.2019.03.12.23.35.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 12 Mar 2019 23:35:05 -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=dS3FAoHE; 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]:39244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3xTk-0005fJ-Og for patch@linaro.org; Wed, 13 Mar 2019 02:35:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3xLm-0000hp-GM for qemu-devel@nongnu.org; Wed, 13 Mar 2019 02:26:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3xLk-00022F-Lk for qemu-devel@nongnu.org; Wed, 13 Mar 2019 02:26:50 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:41151) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3xLi-000201-5M for qemu-devel@nongnu.org; Wed, 13 Mar 2019 02:26:46 -0400 Received: by mail-pf1-x444.google.com with SMTP id d25so656017pfn.8 for ; Tue, 12 Mar 2019 23:26:41 -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=URg26ke8pptD4/rvcTYVkJk/irN25dGRogOZ9l3dOw0=; b=dS3FAoHELYL2MV7G8GTDTECXtKyskTPhm7ft1GWJOmlWOIQDNn6jJSCfiRbMslmTLC M78c5niYkIWlgclhWl8FwbIvdKSJIAU54Q9YQoNO+z+K0qQYqmDlknryBn/FyRGKyrUH Ep1C9cZ98DAjndiJ/HumttR/4BZZnUqQyWJR5OTkfzmk8aYvP5Vo0nRS042feD7/yGD7 PDYls+zQTRyYq1/nBhsQ+AtQby9R3N0AyHJuvxnQ3zYrNwlRFO7ID2iaPit5cEq5AG9n e9wP7XL8KSLwrn6G3cR5tZ3hBQHnkCp1JFfK5NdjWinruCBacnDcB9n+wpAeDOzdaxSd qBXw== 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=URg26ke8pptD4/rvcTYVkJk/irN25dGRogOZ9l3dOw0=; b=eMdKg0p99fdmhp19GphDs+fjOblTjqDT3jYE4pZdQxj/y+roAbucpIygUs8fdtEkm/ OOMP1r8mYgC+Z6GOjiZJ/o0itvg7AgAAfY/Nnd0udojxCACAwft79A71ABUChxiipM3U RKnXsG/pS8jPjnVRZNY6+zOX6OmphHBtjG1JYBhb1TfnZDNXr3Xle3bqqXe6suF2oepx qShOxxYqowA6GrzGl+bfJgQU5FTduUEt3NPrBnHFiJpAIq5Eka6dPs5piobQ4bVCkubm QN9Ck8H/3s2AryiABYT/MlxS/gFNQccZQPvksuaoPX6Q2dZtqEeyJl754cAmfFAM/KX1 mv8g== X-Gm-Message-State: APjAAAUb4MAqfhZnSME+Uo/Y6yt8EPZq6icCZ1ewYFaUXyGoTawnuQI4 RwCdECdkMaN10eGcUzcVaaZ4kJYw/5k= X-Received: by 2002:a63:fd03:: with SMTP id d3mr38012133pgh.359.1552458399765; Tue, 12 Mar 2019 23:26:39 -0700 (PDT) Received: from localhost.localdomain (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id m64sm25593889pfi.149.2019.03.12.23.26.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Mar 2019 23:26:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Mar 2019 23:26:29 -0700 Message-Id: <20190313062630.30568-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190313062630.30568-1-richard.henderson@linaro.org> References: <20190313062630.30568-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::444 Subject: [Qemu-devel] [PATCH for-4.1 6/7] ui/vnc: Use qemu_getrandom for make_challenge 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, david@redhat.com, laurent@vivier.eu, armbru@redhat.com, kraxel@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use a better interface for random numbers than rand, plus some useless floating point arithmetic. Signed-off-by: Richard Henderson --- ui/vnc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) -- 2.17.1 Reviewed-by: Gerd Hoffmann diff --git a/ui/vnc.c b/ui/vnc.c index 1871422e1d..cbdfa37c52 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -46,6 +46,7 @@ #include "qom/object_interfaces.h" #include "qemu/cutils.h" #include "io/dns-resolver.h" +#include "qemu/random.h" #define VNC_REFRESH_INTERVAL_BASE GUI_REFRESH_INTERVAL_DEFAULT #define VNC_REFRESH_INTERVAL_INC 50 @@ -2537,12 +2538,7 @@ void start_client_init(VncState *vs) static void make_challenge(VncState *vs) { - int i; - - srand(time(NULL)+getpid()+getpid()*987654+rand()); - - for (i = 0 ; i < sizeof(vs->challenge) ; i++) - vs->challenge[i] = (int) (256.0*rand()/(RAND_MAX+1.0)); + qemu_getrandom(vs->challenge, sizeof(vs->challenge), false); } static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len)