diff --git a/subsys/random/rand32_xoroshiro128.c b/subsys/random/rand32_xoroshiro128.c index 280d41c08fb..bd793c9bd6c 100644 --- a/subsys/random/rand32_xoroshiro128.c +++ b/subsys/random/rand32_xoroshiro128.c @@ -106,7 +106,7 @@ void z_impl_sys_rand_get(void *dst, size_t outlen) while (len < outlen) { ret = xoroshiro128_next(); if ((outlen-len) < sizeof(ret)) { - blocksize = len; + blocksize = outlen - len; (void)memcpy(udst, &ret, blocksize); } else { (*udst++) = ret;