diff options
author | Astonex <softukitu@gmail.com> | 2013-07-31 23:02:09 +0100 |
---|---|---|
committer | Astonex <softukitu@gmail.com> | 2013-07-31 23:02:09 +0100 |
commit | f05aa308701f33f3bf9df022a4b376deeedef235 (patch) | |
tree | c10b8a3cca6822400853bfd3bc2c5fd1cca73f83 /other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c | |
parent | 8dfba27242ca23fca5de852541f2101568dbf7cb (diff) | |
parent | c558cb63f6db35bd51f2f2331e21df03105ee82a (diff) |
Merge remote-tracking branch 'ProjectTox/master'
Diffstat (limited to 'other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c')
-rw-r--r-- | other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c index 8e278b28..4f28fb3c 100644 --- a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c +++ b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c | |||
@@ -123,11 +123,12 @@ void manage_keys(char *keys_file) | |||
123 | { | 123 | { |
124 | const uint32_t KEYS_SIZE = crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES; | 124 | const uint32_t KEYS_SIZE = crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES; |
125 | uint8_t keys[KEYS_SIZE]; | 125 | uint8_t keys[KEYS_SIZE]; |
126 | 126 | struct stat existence; | |
127 | /* TODO: stat the file before trying to open it. We aren't cave people! */ | 127 | FILE *keysf; |
128 | FILE *keysf = fopen(keys_file, "r"); | 128 | |
129 | if (keysf != NULL) { | 129 | /* Check if file exits, proceed to open and load keys */ |
130 | /* if file was opened successfully -- load keys */ | 130 | if(stat(keys_file,&existence) >= 0) { |
131 | keysf = fopen(keys_file, "r"); | ||
131 | size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keysf); | 132 | size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keysf); |
132 | if (read_size != KEYS_SIZE) { | 133 | if (read_size != KEYS_SIZE) { |
133 | printf("Error while reading the key file\nExiting.\n"); | 134 | printf("Error while reading the key file\nExiting.\n"); |