Skip to content

Commit

Permalink
Pass "b" for fopen to fix bugs on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Tha14 committed Jan 24, 2022
1 parent ade11eb commit 5a88159
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions other/DHT_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void manage_keys(DHT *dht)
enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE };
uint8_t keys[KEYS_SIZE];

FILE *keys_file = fopen("key", "r");
FILE *keys_file = fopen("key", "rb");

if (keys_file != nullptr) {
/* If file was opened successfully -- load keys,
Expand All @@ -62,7 +62,7 @@ static void manage_keys(DHT *dht)
} else {
memcpy(keys, dht_get_self_public_key(dht), CRYPTO_PUBLIC_KEY_SIZE);
memcpy(keys + CRYPTO_PUBLIC_KEY_SIZE, dht_get_self_secret_key(dht), CRYPTO_SECRET_KEY_SIZE);
keys_file = fopen("key", "w");
keys_file = fopen("key", "wb");

if (keys_file == nullptr) {
printf("Error opening key file in write mode.\nKeys will not be saved.\n");
Expand Down
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
edd2f14612df27c7211c2b0c87e714341c4cf4ada868741b2e7f73e1539f30e7 /usr/local/bin/tox-bootstrapd
bfccf7abbe1105994711289ce930ce8f082027ea1370248f2d2d4528dd471b99 /usr/local/bin/tox-bootstrapd
4 changes: 2 additions & 2 deletions other/bootstrap_daemon/src/tox-bootstrapd.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static int manage_keys(DHT *dht, char *keys_file_path)
FILE *keys_file;

// Check if file exits, proceed to open and load keys
keys_file = fopen(keys_file_path, "r");
keys_file = fopen(keys_file_path, "rb");

if (keys_file != nullptr) {
const size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keys_file);
Expand All @@ -79,7 +79,7 @@ static int manage_keys(DHT *dht, char *keys_file_path)
memcpy(keys, dht_get_self_public_key(dht), CRYPTO_PUBLIC_KEY_SIZE);
memcpy(keys + CRYPTO_PUBLIC_KEY_SIZE, dht_get_self_secret_key(dht), CRYPTO_SECRET_KEY_SIZE);

keys_file = fopen(keys_file_path, "w");
keys_file = fopen(keys_file_path, "wb");

if (!keys_file) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion other/fun/save-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

static bool write_save(const uint8_t *data, size_t length)
{
FILE *fp = fopen(GENERATED_SAVE_FILE, "w");
FILE *fp = fopen(GENERATED_SAVE_FILE, "wb");

if (!fp) {
return false;
Expand Down

0 comments on commit 5a88159

Please sign in to comment.