util/guest-random: Fix size arg to tail memcpy
PATCH 1/1 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.
--- util/guest-random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util/guest-random.c +1 -1
@@ -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 ; }
Signature · 1 line
2.30.2
Quoted 9 lines · Mark Nelson
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.
Signed-off-by Mark Nelson<[email protected]>--- util/guest-random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Quoted 5 lines · Mark Nelson
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.
Oops.
routines")
Quoted 19 lines
Signed-off-by Mark Nelson <[email protected]>--- util/guest-random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)util/guest-random.c +1
-1@@ -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 ; }
Laurent Vivier
AppliedLe 09/07/2021 à 14:06, Mark Nelson a écrit :
Quoted 16 lines
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.
Signed-off-by Mark Nelson <[email protected]>--- util/guest-random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)util/guest-random.c +0
-0
util/guest-random.c static int glib_random_bytes(void *buf, size_t len) · line 44
Quoted 8 lines
util/guest-random.c +1
-1@@ -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 ; }
Applied to my trivial-patches branch.
Thanks,
Laurent