Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblinphone
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Board
Labels
Milestones
Merge Requests
21
Merge Requests
21
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
liblinphone
Commits
1c80e72c
Commit
1c80e72c
authored
Jun 26, 2017
by
Benjamin REIS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recreate ZRTP DB file when corrupted and test
parent
25010f05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
1 deletion
+98
-1
linphonecore.c
coreapi/linphonecore.c
+7
-0
call_single_tester.c
tester/call_single_tester.c
+91
-1
No files found.
coreapi/linphonecore.c
View file @
1c80e72c
...
...
@@ -6595,6 +6595,9 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName) {
#ifdef SQLITE_STORAGE_ENABLED
int
ret
;
const
char
*
errmsg
;
const
char
*
backupExtension
=
"_backup"
;
char
*
backupName
=
malloc
(
snprintf
(
NULL
,
0
,
"%s%s"
,
fileName
,
backupExtension
)
+
1
);
sprintf
(
backupName
,
"%s%s"
,
fileName
,
backupExtension
);
sqlite3
*
db
;
linphone_core_zrtp_cache_close
(
lc
);
...
...
@@ -6604,6 +6607,8 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName) {
errmsg
=
sqlite3_errmsg
(
db
);
ms_error
(
"Error in the opening zrtp_cache_db_file(%s): %s.
\n
"
,
fileName
,
errmsg
);
sqlite3_close
(
db
);
unlink
(
backupName
);
rename
(
fileName
,
backupName
);
lc
->
zrtp_cache_db
=
NULL
;
return
;
}
...
...
@@ -6617,6 +6622,8 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName) {
}
else
if
(
ret
!=
0
)
{
/* something went wrong */
ms_error
(
"Zrtp cache failed to initialise(returned -%x), run cacheless"
,
-
ret
);
sqlite3_close
(
db
);
unlink
(
backupName
);
rename
(
fileName
,
backupName
);
lc
->
zrtp_cache_db
=
NULL
;
return
;
}
...
...
tester/call_single_tester.c
View file @
1c80e72c
...
...
@@ -6032,6 +6032,95 @@ static void call_with_network_reachable_down_in_callback(void){
linphone_core_manager_destroy
(
marie
);
}
static
void
recreate_zrtpdb_when_corrupted
(
void
)
{
#ifdef SQLITE_STORAGE_ENABLED
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_tcp_rc"
);
if
(
BC_ASSERT_TRUE
(
linphone_core_media_encryption_supported
(
marie
->
lc
,
LinphoneMediaEncryptionZRTP
)))
{
void
*
db
;
const
char
*
db_file
;
const
char
*
filepath
;
const
char
*
filepath2
;
const
char
*
corrupt
=
"corrupt mwahahahaha"
;
FILE
*
f
;
remove
(
bc_tester_file
(
"tmpZIDCacheMarie.sqlite"
));
filepath
=
bc_tester_file
(
"tmpZIDCacheMarie.sqlite"
);
remove
(
bc_tester_file
(
"tmpZIDCachePauline.sqlite"
));
filepath2
=
bc_tester_file
(
"tmpZIDCachePauline.sqlite"
);
linphone_core_set_media_encryption
(
marie
->
lc
,
LinphoneMediaEncryptionZRTP
);
linphone_core_set_media_encryption
(
pauline
->
lc
,
LinphoneMediaEncryptionZRTP
);
linphone_core_set_zrtp_secrets_file
(
marie
->
lc
,
filepath
);
linphone_core_set_zrtp_secrets_file
(
pauline
->
lc
,
filepath2
);
BC_ASSERT_TRUE
(
call
(
pauline
,
marie
));
linphone_call_set_authentication_token_verified
(
linphone_core_get_current_call
(
marie
->
lc
),
TRUE
);
linphone_call_set_authentication_token_verified
(
linphone_core_get_current_call
(
pauline
->
lc
),
TRUE
);
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
marie
->
lc
)));
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
pauline
->
lc
)));
end_call
(
marie
,
pauline
);
db
=
linphone_core_get_zrtp_cache_db
(
marie
->
lc
);
BC_ASSERT_PTR_NOT_NULL
(
db
);
BC_ASSERT_TRUE
(
call
(
pauline
,
marie
));
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
marie
->
lc
)));
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
pauline
->
lc
)));
end_call
(
marie
,
pauline
);
//Corrupt db file
db_file
=
linphone_core_get_zrtp_secrets_file
(
marie
->
lc
);
BC_ASSERT_PTR_NOT_NULL
(
db_file
);
f
=
fopen
(
db_file
,
"wb"
);
fwrite
(
corrupt
,
1
,
sizeof
(
corrupt
),
f
);
fclose
(
f
);
//Simulate relaunch of linphone core marie
linphone_core_set_zrtp_secrets_file
(
marie
->
lc
,
filepath
);
db
=
linphone_core_get_zrtp_cache_db
(
marie
->
lc
);
BC_ASSERT_PTR_NULL
(
db
);
BC_ASSERT_TRUE
(
call
(
pauline
,
marie
));
linphone_call_set_authentication_token_verified
(
linphone_core_get_current_call
(
marie
->
lc
),
TRUE
);
linphone_call_set_authentication_token_verified
(
linphone_core_get_current_call
(
pauline
->
lc
),
TRUE
);
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
marie
->
lc
)));
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
pauline
->
lc
)));
end_call
(
marie
,
pauline
);
BC_ASSERT_TRUE
(
call
(
pauline
,
marie
));
BC_ASSERT_FALSE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
marie
->
lc
)));
BC_ASSERT_FALSE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
pauline
->
lc
)));
end_call
(
marie
,
pauline
);
//Db file should be recreated after corruption
//Simulate relaunch of linphone core marie
linphone_core_set_zrtp_secrets_file
(
marie
->
lc
,
filepath
);
BC_ASSERT_TRUE
(
call
(
pauline
,
marie
));
linphone_call_set_authentication_token_verified
(
linphone_core_get_current_call
(
marie
->
lc
),
TRUE
);
linphone_call_set_authentication_token_verified
(
linphone_core_get_current_call
(
pauline
->
lc
),
TRUE
);
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
marie
->
lc
)));
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
pauline
->
lc
)));
end_call
(
marie
,
pauline
);
db
=
linphone_core_get_zrtp_cache_db
(
marie
->
lc
);
BC_ASSERT_PTR_NOT_NULL
(
db
);
db_file
=
linphone_core_get_zrtp_secrets_file
(
marie
->
lc
);
BC_ASSERT_PTR_NOT_NULL
(
db_file
);
BC_ASSERT_TRUE
(
call
(
pauline
,
marie
));
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
marie
->
lc
)));
BC_ASSERT_TRUE
(
linphone_call_get_authentication_token_verified
(
linphone_core_get_current_call
(
pauline
->
lc
)));
end_call
(
marie
,
pauline
);
}
linphone_core_manager_destroy
(
marie
);
linphone_core_manager_destroy
(
pauline
);
#endif
/* SQLITE_STORAGE_ENABLED */
}
test_t
call_tests
[]
=
{
TEST_NO_TAG
(
"Early declined call"
,
early_declined_call
),
TEST_NO_TAG
(
"Call declined"
,
call_declined
),
...
...
@@ -6182,7 +6271,8 @@ test_t call_tests[] = {
TEST_NO_TAG
(
"Call terminated with reason"
,
terminate_call_with_error
),
TEST_NO_TAG
(
"Call cancelled with reason"
,
cancel_call_with_error
),
TEST_NO_TAG
(
"Call accepted, other ringing device receive CANCEL with reason"
,
cancel_other_device_after_accept
),
TEST_NO_TAG
(
"Call declined, other ringing device receive CANCEL with reason"
,
cancel_other_device_after_decline
)
TEST_NO_TAG
(
"Call declined, other ringing device receive CANCEL with reason"
,
cancel_other_device_after_decline
),
TEST_NO_TAG
(
"Recreate ZRTP db file when corrupted"
,
recreate_zrtpdb_when_corrupted
)
};
test_suite_t
call_test_suite
=
{
"Single Call"
,
NULL
,
NULL
,
liblinphone_tester_before_each
,
liblinphone_tester_after_each
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment