Use unbuffered stdio for /dev/urandom to read only requested data (#391)

Buffered fread() reads 4096 bytes which is completely unnecessary and potentially may cause problems.
I discovered this on private linux configuration where custom /dev/urandom implementation has poor performance.

Fix By: @vburdo
pull/394/head
vburdo 4 years ago committed by GitHub
parent 5ff0f6aa53
commit 44fbc81368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/lib/ares_init.c

@ -2473,6 +2473,7 @@ static void randomize_key(unsigned char* key,int key_data_len)
#ifdef RANDOM_FILE
FILE *f = fopen(RANDOM_FILE, "rb");
if(f) {
setvbuf(f, NULL, _IONBF, 0);
counter = aresx_uztosi(fread(key, 1, key_data_len, f));
fclose(f);
}

Loading…
Cancel
Save