Skip to content
Snippets Groups Projects
Commit e28ffe90 authored by Mark Nelson's avatar Mark Nelson Committed by Laurent Vivier
Browse files

util/guest-random: Fix size arg to tail memcpy


We know that in the body of this if statement i is less than len, so
we really should be copying len - i bytes not i - len bytes.

Fix this typo.

Fixes: 8d8404f1 ("util: Add qemu_guest_getrandom and associated routines")
Signed-off-by: default avatarMark Nelson <mdnelson8@gmail.com>
Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210709120600.11080-1-mdnelson8@gmail.com>
Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
parent 179a8080
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ static int glib_random_bytes(void *buf, size_t len)
}
if (i < len) {
x = g_rand_int(rand);
__builtin_memcpy(buf + i, &x, i - len);
__builtin_memcpy(buf + i, &x, len - i);
}
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment