summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-11-29 23:45:32 -0500
committerirungentoo <irungentoo@gmail.com>2014-11-29 23:45:32 -0500
commitee0f06937fc22e69f4849a781b2b3d40af639069 (patch)
treeb71a0f162b01804c1bafb1c6bf2d7e78d5c753f8
parent1c3f88758db4325de36294c9f4682980c4198cc7 (diff)
Check if key file was opened correctly in DHT_bootstrap.c
Warn the user if it wasn't.
-rw-r--r--other/DHT_bootstrap.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index 462360c3..29aa5bcf 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -83,6 +83,11 @@ void manage_keys(DHT *dht)
83 memcpy(keys + crypto_box_PUBLICKEYBYTES, dht->self_secret_key, crypto_box_SECRETKEYBYTES); 83 memcpy(keys + crypto_box_PUBLICKEYBYTES, dht->self_secret_key, crypto_box_SECRETKEYBYTES);
84 keys_file = fopen("key", "w"); 84 keys_file = fopen("key", "w");
85 85
86 if (keys_file == NULL) {
87 printf("Error opening key file in write mode.\nKeys will not be saved.\n");
88 return;
89 }
90
86 if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) { 91 if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) {
87 printf("Error while writing the key file.\nExiting.\n"); 92 printf("Error while writing the key file.\nExiting.\n");
88 exit(1); 93 exit(1);