fix opening the file in the wrong mode

pull/6932/head
paul-szczepanek-arm 2018-05-22 12:11:07 +01:00
parent 7d916a9997
commit 1cd0c20fd0
1 changed files with 8 additions and 1 deletions

View File

@ -90,9 +90,16 @@ FILE* FileSecurityDb::open_db_file(const char *db_path) {
return NULL;
}
FILE *db_file = fopen(db_path, "wb+");
/* try to open an existing file */
FILE *db_file = fopen(db_path, "rb+");
if (!db_file) {
/* file doesn't exist, create it */
db_file = fopen(db_path, "wb+");
}
if (!db_file) {
/* failed to create a file, abort */
return NULL;
}