Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
Merge pull request #5 from cvtsi2sd/master
Browse files Browse the repository at this point in the history
Fix undefined behavior in random_genXX helpers
  • Loading branch information
asterix24 committed Jan 23, 2017
2 parents bce3c17 + 5e53f91 commit 1f5efa0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bertos/sec/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ void random_gen(uint8_t *out, size_t len);
INLINE uint8_t random_gen8(void)
{
uint8_t x;
random_gen(&x, 1);
random_gen(&x, sizeof(x));
return x;
}

INLINE uint16_t random_gen16(void)
{
uint8_t x;
random_gen(&x, 2);
uint16_t x;
random_gen((uint8_t *)&x, sizeof(x));
return x;
}

INLINE uint32_t random_gen32(void)
{
uint8_t x;
random_gen(&x, 4);
uint32_t x;
random_gen((uint8_t *)&x, sizeof(x));
return x;
}

Expand Down

0 comments on commit 1f5efa0

Please sign in to comment.