logger(mesh, MESHLINK_DEBUG, "Done.\n");
snprintf(privname, sizeof privname, "%s" SLASH "ecdsa_key.priv", mesh->confbase);
- f = fopen(privname, "w");
+ f = fopen(privname, "wb");
if(!f) {
meshlink_errno = MESHLINK_ESTORAGE;
}
// Create a new key if necessary.
- FILE *f = fopen(filename, "r");
+ FILE *f = fopen(filename, "rb");
if(!f) {
if(errno != ENOENT) {
logger(mesh, MESHLINK_DEBUG, "Could not read %s: %s\n", filename, strerror(errno));
pthread_mutex_unlock(&(mesh->mesh_mutex));
return false;
}
- f = fopen(filename, "w");
+ f = fopen(filename, "wb");
if(!f) {
logger(mesh, MESHLINK_DEBUG, "Could not write %s: %s\n", filename, strerror(errno));
meshlink_errno = MESHLINK_ESTORAGE;
char filename[PATH_MAX];
snprintf(filename,PATH_MAX, "%s" SLASH "ecdsa_key.priv", mesh->confbase);
- fp = fopen(filename, "r");
+ fp = fopen(filename, "rb");
if(!fp) {
logger(mesh, MESHLINK_ERROR, "Error reading ECDSA private key file: %s", strerror(errno));
snprintf(filename,PATH_MAX, "%s" SLASH "invitations" SLASH "ecdsa_key.priv", mesh->confbase);
- fp = fopen(filename, "r");
+ fp = fopen(filename, "rb");
if(fp) {
mesh->invitation_key = ecdsa_read_pem_private_key(fp);