mirror of
https://github.com/bol-van/zapret2.git
synced 2026-03-14 06:13:09 +00:00
nfqws2: fix sz=0 case in fill_random_bytes
This commit is contained in:
@@ -456,11 +456,14 @@ bool file_open_test(const char *filename, int flags)
|
|||||||
void fill_random_bytes(uint8_t *p,size_t sz)
|
void fill_random_bytes(uint8_t *p,size_t sz)
|
||||||
{
|
{
|
||||||
size_t k;
|
size_t k;
|
||||||
// alignment
|
if (sz)
|
||||||
if ((size_t)p & 1) { *p=(uint8_t)random(); sz--; p++; }
|
{
|
||||||
// random has only 31 bits of entropy. not 32 bits
|
// alignment
|
||||||
for (k=0 ; (k+1)<sz ; k+=2) *(uint16_t*)(p+k) = (uint16_t)random();
|
if ((size_t)p & 1) { *p=(uint8_t)random(); sz--; p++; }
|
||||||
if (sz & 1) p[sz-1]=(uint8_t)random();
|
// random has only 31 bits of entropy. not 32 bits
|
||||||
|
for (k=0 ; (k+1)<sz ; k+=2) *(uint16_t*)(p+k) = (uint16_t)random();
|
||||||
|
if (sz & 1) p[sz-1]=(uint8_t)random();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void fill_random_az(uint8_t *p,size_t sz)
|
void fill_random_az(uint8_t *p,size_t sz)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user