diff options
author | Jouni Malinen <j@w1.fi> | 2011-08-06 21:16:31 +0300 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2011-08-06 21:16:31 +0300 |
commit | 2e923102171e5dacd2a1affda70d506a9ef433c7 (patch) | |
tree | 8140e347dfed92e487d3400a9c49bcad0cf7cad5 | |
parent | 6921f1f3860e8e3c1a6148b586a5b5bb406b6656 (diff) | |
download | external_wpa_supplicant_8_ti-2e923102171e5dacd2a1affda70d506a9ef433c7.zip external_wpa_supplicant_8_ti-2e923102171e5dacd2a1affda70d506a9ef433c7.tar.gz external_wpa_supplicant_8_ti-2e923102171e5dacd2a1affda70d506a9ef433c7.tar.bz2 |
random: Check fwrite return value to avoid warnings
Some compilers complain about fwrite calls if the return value is
not checked, so check the value even if it does not really make
much of a difference in this particular case.
-rw-r--r-- | src/crypto/random.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/crypto/random.c b/src/crypto/random.c index 7f5c08a..5b15354 100644 --- a/src/crypto/random.c +++ b/src/crypto/random.c @@ -354,6 +354,7 @@ static void random_write_entropy(void) char buf[RANDOM_ENTROPY_SIZE]; FILE *f; u8 opr; + int fail = 0; if (!random_entropy_file) return; @@ -369,9 +370,15 @@ static void random_write_entropy(void) } opr = own_pool_ready > 0xff ? 0xff : own_pool_ready; - fwrite(&opr, 1, 1, f); - fwrite(buf, RANDOM_ENTROPY_SIZE, 1, f); + if (fwrite(&opr, 1, 1, f) != 1 || + fwrite(buf, RANDOM_ENTROPY_SIZE, 1, f) != 1) + fail = 1; fclose(f); + if (fail) { + wpa_printf(MSG_ERROR, "random: Could not entropy data to %s", + random_entropy_file); + return; + } wpa_printf(MSG_DEBUG, "random: Updated entropy file %s " "(own_pool_ready=%u)", |