diff options
-rw-r--r-- | testing/DHT_test.c | 2 | ||||
-rw-r--r-- | testing/nTox.c | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c index 5895fa55..368609d0 100644 --- a/testing/DHT_test.c +++ b/testing/DHT_test.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* DHT test | 1 | /* DHT test |
2 | * A file with a main that runs our DHT for testing. | 2 | * A file with a main that runs our DHT for testing. |
3 | * | 3 | * |
4 | * Compile with: gcc -O2 -Wall -D VANILLA_NACL -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/Messenger.c ../nacl/build/${HOSTNAME%.*}/lib/amd64/ DHT_test.c | 4 | * Compile with: gcc -O2 -Wall -D VANILLA_NACL -o test ../core/Lossless_UDP.c ../core/network.c ../core/net_crypto.c ../core/Messenger.c ../nacl/build/${HOSTNAME%.*}/lib/amd64/{cpucycles.o,libnacl.a,randombytes.o} DHT_test.c |
5 | * | 5 | * |
6 | * Command line arguments are the ip, port and public key of a node. | 6 | * Command line arguments are the ip, port and public key of a node. |
7 | * EX: ./test 127.0.0.1 33445 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | 7 | * EX: ./test 127.0.0.1 33445 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
diff --git a/testing/nTox.c b/testing/nTox.c index 199835a6..faa6cfa5 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -229,7 +229,11 @@ int main(int argc, char *argv[]) | |||
229 | int size = ftell(data_file); | 229 | int size = ftell(data_file); |
230 | fseek(data_file, 0, SEEK_SET); | 230 | fseek(data_file, 0, SEEK_SET); |
231 | uint8_t data[size]; | 231 | uint8_t data[size]; |
232 | fread(data, sizeof(uint8_t), size, data_file); | 232 | if(fread(data, sizeof(uint8_t), size, data_file) != size) |
233 | { | ||
234 | printf("Error reading file\n"); | ||
235 | exit(0); | ||
236 | } | ||
233 | Messenger_load(data, size); | 237 | Messenger_load(data, size); |
234 | } else { | 238 | } else { |
235 | //else save new keys | 239 | //else save new keys |
@@ -237,7 +241,11 @@ int main(int argc, char *argv[]) | |||
237 | uint8_t data[size]; | 241 | uint8_t data[size]; |
238 | Messenger_save(data); | 242 | Messenger_save(data); |
239 | data_file = fopen("data","w"); | 243 | data_file = fopen("data","w"); |
240 | fwrite(data, sizeof(uint8_t), size, data_file); | 244 | if(fwrite(data, sizeof(uint8_t), size, data_file) != size) |
245 | { | ||
246 | printf("Error writing file\n"); | ||
247 | exit(0); | ||
248 | } | ||
241 | } | 249 | } |
242 | fclose(data_file); | 250 | fclose(data_file); |
243 | m_callback_friendrequest(print_request); | 251 | m_callback_friendrequest(print_request); |