[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-4.1 6/7] ui/vnc: Use qemu_getrandom for make_cha
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH for-4.1 6/7] ui/vnc: Use qemu_getrandom for make_challenge |
Date: |
Tue, 12 Mar 2019 23:26:29 -0700 |
Use a better interface for random numbers than rand,
plus some useless floating point arithmetic.
Signed-off-by: Richard Henderson <address@hidden>
---
ui/vnc.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
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)
--
2.17.1
- [Qemu-devel] [PATCH for-4.1 0/7] Add qemu_getrandom and ARMv8.5-RNG, Richard Henderson, 2019/03/13
- [Qemu-devel] [PATCH for-4.1 4/7] linux-user/aarch64: Use qemu_getrandom for arm_init_pauth_key, Richard Henderson, 2019/03/13
- [Qemu-devel] [PATCH for-4.1 2/7] util: Use getrandom for qemu_getrandom if available, Richard Henderson, 2019/03/13
- [Qemu-devel] [PATCH for-4.1 5/7] linux-user: Remove srand call, Richard Henderson, 2019/03/13
- [Qemu-devel] [PATCH for-4.1 3/7] linux-user: Use qemu_getrandom for AT_RANDOM, Richard Henderson, 2019/03/13
- [Qemu-devel] [PATCH for-4.1 1/7] util: Add qemu_getrandom and support functions, Richard Henderson, 2019/03/13
- [Qemu-devel] [PATCH for-4.1 6/7] ui/vnc: Use qemu_getrandom for make_challenge,
Richard Henderson <=
- [Qemu-devel] [PATCH for-4.1 7/7] target/arm: Implement ARMv8.5-RNG, Richard Henderson, 2019/03/13
- Re: [Qemu-devel] [PATCH for-4.1 0/7] Add qemu_getrandom and ARMv8.5-RNG, no-reply, 2019/03/13
- Re: [Qemu-devel] [PATCH for-4.1 0/7] Add qemu_getrandom and ARMv8.5-RNG, Daniel P . Berrangé, 2019/03/13
- Re: [Qemu-devel] [PATCH for-4.1 0/7] Add qemu_getrandom and ARMv8.5-RNG, Richard Henderson, 2019/03/13
- Re: [Qemu-devel] [PATCH for-4.1 0/7] Add qemu_getrandom and ARMv8.5-RNG, Daniel P . Berrangé, 2019/03/14