Skip to content

Commit 1cd0c20

Browse files
fix opening the file in the wrong mode
1 parent 7d916a9 commit 1cd0c20

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

features/FEATURE_BLE/source/generic/FileSecurityDb.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,16 @@ FILE* FileSecurityDb::open_db_file(const char *db_path) {
9090
return NULL;
9191
}
9292

93-
FILE *db_file = fopen(db_path, "wb+");
93+
/* try to open an existing file */
94+
FILE *db_file = fopen(db_path, "rb+");
9495

9596
if (!db_file) {
97+
/* file doesn't exist, create it */
98+
db_file = fopen(db_path, "wb+");
99+
}
100+
101+
if (!db_file) {
102+
/* failed to create a file, abort */
96103
return NULL;
97104
}
98105

0 commit comments

Comments
 (0)