Fix buffer overrun and use correct size for random u32

This commit is contained in:
Nicolas Stalder 2019-03-26 01:55:42 +01:00
parent 98a209e330
commit 40b9dae38a

View File

@ -17,7 +17,7 @@ int __errno = 0;
void rng_get_bytes(uint8_t * dst, size_t sz) void rng_get_bytes(uint8_t * dst, size_t sz)
{ {
uint8_t r[8]; uint8_t r[4];
unsigned int i,j; unsigned int i,j;
for (i = 0; i < sz; i += 4) for (i = 0; i < sz; i += 4)
{ {
@ -33,7 +33,7 @@ void rng_get_bytes(uint8_t * dst, size_t sz)
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
if ((i + j) > sz) if ((i + j) >= sz)
{ {
return; return;
} }