Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
2dd2ee6e
Commit
2dd2ee6e
authored
Jul 31, 2017
by
Simon Morlat
Browse files
fix memory leaks
parent
3f3c114a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
57 additions
and
43 deletions
+57
-43
coreapi/chat.c
coreapi/chat.c
+4
-4
coreapi/chat_file_transfer.c
coreapi/chat_file_transfer.c
+1
-1
coreapi/friendlist.c
coreapi/friendlist.c
+4
-4
coreapi/lime.c
coreapi/lime.c
+14
-7
coreapi/linphonecore.c
coreapi/linphonecore.c
+5
-4
coreapi/presence.c
coreapi/presence.c
+14
-14
coreapi/private.h
coreapi/private.h
+2
-2
coreapi/xml.c
coreapi/xml.c
+3
-3
coreapi/xmlrpc.c
coreapi/xmlrpc.c
+1
-1
tester/message_tester.c
tester/message_tester.c
+9
-3
No files found.
coreapi/chat.c
View file @
2dd2ee6e
...
...
@@ -784,8 +784,8 @@ static const char *iscomposing_prefix = "/xsi:isComposing";
static
void
process_im_is_composing_notification
(
LinphoneChatRoom
*
cr
,
xmlparsing_context_t
*
xml_ctx
)
{
char
xpath_str
[
MAX_XPATH_LENGTH
];
xmlXPathObjectPtr
iscomposing_object
;
const
char
*
state_str
=
NULL
;
const
char
*
refresh_str
=
NULL
;
char
*
state_str
=
NULL
;
char
*
refresh_str
=
NULL
;
int
refresh_duration
=
lp_config_get_int
(
cr
->
lc
->
config
,
"sip"
,
"composing_remote_refresh_timeout"
,
COMPOSING_DEFAULT_REMOTE_REFRESH_TIMEOUT
);
int
i
;
...
...
@@ -860,8 +860,8 @@ static void process_imdn(LinphoneChatRoom *cr, xmlparsing_context_t *xml_ctx) {
xmlXPathObjectPtr
imdn_object
;
xmlXPathObjectPtr
delivery_status_object
;
xmlXPathObjectPtr
display_status_object
;
const
char
*
message_id_str
=
NULL
;
const
char
*
datetime_str
=
NULL
;
char
*
message_id_str
=
NULL
;
char
*
datetime_str
=
NULL
;
LinphoneCore
*
lc
=
linphone_chat_room_get_core
(
cr
);
LinphoneImNotifPolicy
*
policy
=
linphone_core_get_im_notif_policy
(
lc
);
...
...
coreapi/chat_file_transfer.c
View file @
2dd2ee6e
...
...
@@ -335,7 +335,7 @@ static void linphone_chat_message_process_response_from_post_file(void *data,
}
else
{
/* no encryption key, transfer in plain, just copy the msg sent by server */
msg
->
message
=
ms_strdup
(
body
);
}
msg
->
content_type
=
ms_strdup
(
"application/vnd.gsma.rcs-ft-http+xml"
);
linphone_chat_message_set_content_type
(
msg
,
"application/vnd.gsma.rcs-ft-http+xml"
);
linphone_chat_message_ref
(
msg
);
linphone_chat_message_set_state
(
msg
,
LinphoneChatMessageStateFileTransferDone
);
_release_http_request
(
msg
);
...
...
coreapi/friendlist.c
View file @
2dd2ee6e
...
...
@@ -205,9 +205,9 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
LinphoneFriend
*
lf
;
LinphoneContent
*
presence_part
;
xmlXPathObjectPtr
resource_object
;
const
char
*
version_str
=
NULL
;
const
char
*
full_state_str
=
NULL
;
const
char
*
uri
=
NULL
;
char
*
version_str
=
NULL
;
char
*
full_state_str
=
NULL
;
char
*
uri
=
NULL
;
bool_t
full_state
=
FALSE
;
int
version
;
int
i
;
...
...
@@ -249,7 +249,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
resource_object
=
linphone_get_xml_xpath_object_for_node_list
(
xml_ctx
,
"/rlmi:list/rlmi:resource/rlmi:instance[@state=
\"
active
\"
]/.."
);
if
((
resource_object
!=
NULL
)
&&
(
resource_object
->
nodesetval
!=
NULL
))
{
for
(
i
=
1
;
i
<=
resource_object
->
nodesetval
->
nodeNr
;
i
++
)
{
const
char
*
cid
=
NULL
;
char
*
cid
=
NULL
;
linphone_xml_xpath_context_set_node
(
xml_ctx
,
xmlXPathNodeSetItem
(
resource_object
->
nodesetval
,
i
-
1
));
cid
=
linphone_get_xml_text_content
(
xml_ctx
,
"./rlmi:instance/@cid"
);
if
(
cid
!=
NULL
)
{
...
...
coreapi/lime.c
View file @
2dd2ee6e
...
...
@@ -579,7 +579,7 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
uint8_t
selfZid
[
12
];
/* same data but in byte buffer */
char
xpath_str
[
MAX_XPATH_LENGTH
];
limeKey_t
associatedKey
;
const
char
*
peerZidHex
=
NULL
;
char
*
peerZidHex
=
NULL
;
const
char
*
sessionIndexHex
=
NULL
;
xmlparsing_context_t
*
xml_ctx
;
xmlXPathObjectPtr
msg_object
;
...
...
@@ -635,12 +635,14 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
msg_object
=
linphone_get_xml_xpath_object_for_node_list
(
xml_ctx
,
"/doc/msg"
);
if
((
msg_object
!=
NULL
)
&&
(
msg_object
->
nodesetval
!=
NULL
))
{
for
(
i
=
1
;
i
<=
msg_object
->
nodesetval
->
nodeNr
;
i
++
)
{
const
char
*
currentZidHex
;
const
char
*
encryptedMessageb64
;
const
char
*
encryptedContentTypeb64
;
char
*
currentZidHex
;
char
*
encryptedMessageb64
;
char
*
encryptedContentTypeb64
;
snprintf
(
xpath_str
,
sizeof
(
xpath_str
),
"/doc/msg[%i]/pzid"
,
i
);
currentZidHex
=
linphone_get_xml_text_content
(
xml_ctx
,
xpath_str
);
if
((
currentZidHex
!=
NULL
)
&&
(
strcmp
(
currentZidHex
,
(
char
*
)
selfZidHex
)
==
0
))
{
linphone_free_xml_text_content
(
currentZidHex
);
/* We found the msg node we are looking for */
snprintf
(
xpath_str
,
sizeof
(
xpath_str
),
"/doc/msg[%i]/index"
,
i
);
sessionIndexHex
=
linphone_get_xml_text_content
(
xml_ctx
,
xpath_str
);
...
...
@@ -665,9 +667,9 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
}
break
;
}
if
(
currentZidHex
!=
NULL
)
linphone_free_xml_text_content
(
currentZidHex
);
}
}
if
(
msg_object
!=
NULL
)
xmlXPathFreeObject
(
msg_object
);
}
/* do we have retrieved correctly all the needed data */
...
...
@@ -766,6 +768,7 @@ bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) {
return the list of possible uris and store the selected one in the chatroom ? */
res
=
(
lime_getCachedSndKeysByURI
(
zrtp_cache_db
,
&
associatedKeys
)
==
0
);
lime_freeKeys
(
&
associatedKeys
);
ms_free
(
peer
);
return
res
;
}
}
...
...
@@ -795,7 +798,10 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn
}
peerUri
=
linphone_address_as_string_uri_only
(
msg
->
from
);
selfUri
=
linphone_address_as_string_uri_only
(
msg
->
to
);
retval
=
lime_decryptMultipartMessage
(
zrtp_cache_db
,
(
uint8_t
*
)
msg
->
message
,
selfUri
,
peerUri
,
&
decrypted_body
,
&
decrypted_content_type
,
bctbx_time_string_to_sec
(
lp_config_get_string
(
lc
->
config
,
"sip"
,
"lime_key_validity"
,
"0"
)));
retval
=
lime_decryptMultipartMessage
(
zrtp_cache_db
,
(
uint8_t
*
)
msg
->
message
,
selfUri
,
peerUri
,
&
decrypted_body
,
&
decrypted_content_type
,
bctbx_time_string_to_sec
(
lp_config_get_string
(
lc
->
config
,
"sip"
,
"lime_key_validity"
,
"0"
)));
ms_free
(
peerUri
);
ms_free
(
selfUri
);
if
(
retval
!=
0
)
{
ms_warning
(
"Unable to decrypt message, reason : %s"
,
lime_error_code_to_string
(
retval
));
if
(
decrypted_body
)
ms_free
(
decrypted_body
);
...
...
@@ -809,6 +815,7 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn
msg
->
message
=
(
char
*
)
decrypted_body
;
if
(
decrypted_content_type
!=
NULL
)
{
linphone_chat_message_set_content_type
(
msg
,
decrypted_content_type
);
ms_free
(
decrypted_content_type
);
}
else
{
if
(
strcmp
(
"application/cipher.vnd.gsma.rcs-ft-http+xml"
,
msg
->
content_type
)
==
0
)
{
linphone_chat_message_set_content_type
(
msg
,
"application/vnd.gsma.rcs-ft-http+xml"
);
...
...
@@ -863,7 +870,7 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn
ms_free
(
msg
->
message
);
}
msg
->
message
=
(
char
*
)
crypted_body
;
msg
->
content_type
=
ms_strdup
(
new_content_type
);
linphone_chat_message_set_content_type
(
msg
,
new_content_type
);
}
ms_free
(
peerUri
);
ms_free
(
selfUri
);
...
...
coreapi/linphonecore.c
View file @
2dd2ee6e
...
...
@@ -6614,8 +6614,7 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName) {
int
ret
;
const
char
*
errmsg
;
const
char
*
backupExtension
=
"_backup"
;
char
*
backupName
=
reinterpret_cast
<
char
*>
(
malloc
(
snprintf
(
NULL
,
0
,
"%s%s"
,
fileName
,
backupExtension
)
+
1
));
sprintf
(
backupName
,
"%s%s"
,
fileName
,
backupExtension
);
char
*
backupName
=
bctbx_strdup_printf
(
"%s%s"
,
fileName
,
backupExtension
);
sqlite3
*
db
;
linphone_core_zrtp_cache_close
(
lc
);
...
...
@@ -6628,7 +6627,7 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName) {
unlink
(
backupName
);
rename
(
fileName
,
backupName
);
lc
->
zrtp_cache_db
=
NULL
;
return
;
goto
end
;
}
ret
=
ms_zrtp_initCache
((
void
*
)
db
);
/* this may perform an update, check return value */
...
...
@@ -6643,11 +6642,13 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName) {
unlink
(
backupName
);
rename
(
fileName
,
backupName
);
lc
->
zrtp_cache_db
=
NULL
;
return
;
goto
end
;
}
/* everything ok, set the db pointer into core */
lc
->
zrtp_cache_db
=
db
;
end:
if
(
backupName
)
bctbx_free
(
backupName
);
#endif
/* SQLITE_STORAGE_ENABLED */
}
...
...
coreapi/presence.c
View file @
2dd2ee6e
...
...
@@ -1201,8 +1201,8 @@ static int process_pidf_xml_presence_service_notes(xmlparsing_context_t *xml_ctx
char
xpath_str
[
MAX_XPATH_LENGTH
];
xmlXPathObjectPtr
note_object
;
LinphonePresenceNote
*
note
;
const
char
*
note_str
;
const
char
*
lang
;
char
*
note_str
;
char
*
lang
;
int
i
;
snprintf
(
xpath_str
,
sizeof
(
xpath_str
),
"%s[%i]/pidf:note"
,
service_prefix
,
service_idx
);
...
...
@@ -1231,10 +1231,10 @@ static int process_pidf_xml_presence_services(xmlparsing_context_t *xml_ctx, Lin
xmlXPathObjectPtr
service_object
;
xmlXPathObjectPtr
pidfonline_object
;
LinphonePresenceService
*
service
;
const
char
*
basic_status_str
;
const
char
*
service_id_str
;
const
char
*
timestamp_str
;
const
char
*
contact_str
;
char
*
basic_status_str
;
char
*
service_id_str
;
char
*
timestamp_str
;
char
*
contact_str
;
LinphonePresenceBasicStatus
basic_status
;
int
i
;
...
...
@@ -1306,7 +1306,7 @@ static int process_pidf_xml_presence_person_activities(xmlparsing_context_t *xml
xmlXPathObjectPtr
activities_object
;
xmlNodePtr
activity_node
;
LinphonePresenceActivity
*
activity
;
const
char
*
description
;
char
*
description
;
int
i
,
j
;
int
err
=
0
;
...
...
@@ -1321,7 +1321,7 @@ static int process_pidf_xml_presence_person_activities(xmlparsing_context_t *xml
activity_node
=
activities_object
->
nodesetval
->
nodeTab
[
j
];
if
((
activity_node
->
name
!=
NULL
)
&&
(
is_valid_activity_name
((
const
char
*
)
activity_node
->
name
)
==
TRUE
))
{
LinphonePresenceActivityType
acttype
;
description
=
(
const
char
*
)
xmlNodeGetContent
(
activity_node
);
description
=
(
char
*
)
xmlNodeGetContent
(
activity_node
);
if
((
description
!=
NULL
)
&&
(
description
[
0
]
==
'\0'
))
{
linphone_free_xml_text_content
(
description
);
description
=
NULL
;
...
...
@@ -1348,8 +1348,8 @@ static int process_pidf_xml_presence_person_notes(xmlparsing_context_t *xml_ctx,
char
xpath_str
[
MAX_XPATH_LENGTH
];
xmlXPathObjectPtr
note_object
;
LinphonePresenceNote
*
note
;
const
char
*
note_str
;
const
char
*
lang
;
char
*
note_str
;
char
*
lang
;
int
i
;
snprintf
(
xpath_str
,
sizeof
(
xpath_str
),
"%s[%i]/rpid:activities/rpid:note"
,
person_prefix
,
person_idx
);
...
...
@@ -1395,8 +1395,8 @@ static int process_pidf_xml_presence_persons(xmlparsing_context_t *xml_ctx, Linp
char
xpath_str
[
MAX_XPATH_LENGTH
];
xmlXPathObjectPtr
person_object
;
LinphonePresencePerson
*
person
;
const
char
*
person_id_str
;
const
char
*
person_timestamp_str
;
char
*
person_id_str
;
char
*
person_timestamp_str
;
time_t
timestamp
;
int
i
;
int
err
=
0
;
...
...
@@ -1444,8 +1444,8 @@ static int process_pidf_xml_presence_notes(xmlparsing_context_t *xml_ctx, Linpho
char
xpath_str
[
MAX_XPATH_LENGTH
];
xmlXPathObjectPtr
note_object
;
LinphonePresenceNote
*
note
;
const
char
*
note_str
;
const
char
*
lang
;
char
*
note_str
;
char
*
lang
;
int
i
;
note_object
=
linphone_get_xml_xpath_object_for_node_list
(
xml_ctx
,
"/pidf:presence/pidf:note"
);
...
...
coreapi/private.h
View file @
2dd2ee6e
...
...
@@ -1700,8 +1700,8 @@ void linphone_xmlparsing_genericxml_error(void *ctx, const char *fmt, ...);
int
linphone_create_xml_xpath_context
(
xmlparsing_context_t
*
xml_ctx
);
void
linphone_xml_xpath_context_set_node
(
xmlparsing_context_t
*
xml_ctx
,
xmlNodePtr
node
);
char
*
linphone_get_xml_text_content
(
xmlparsing_context_t
*
xml_ctx
,
const
char
*
xpath_expression
);
const
char
*
linphone_get_xml_attribute_text_content
(
xmlparsing_context_t
*
xml_ctx
,
const
char
*
xpath_expression
,
const
char
*
attribute_name
);
void
linphone_free_xml_text_content
(
const
char
*
text
);
char
*
linphone_get_xml_attribute_text_content
(
xmlparsing_context_t
*
xml_ctx
,
const
char
*
xpath_expression
,
const
char
*
attribute_name
);
void
linphone_free_xml_text_content
(
char
*
text
);
xmlXPathObjectPtr
linphone_get_xml_xpath_object_for_node_list
(
xmlparsing_context_t
*
xml_ctx
,
const
char
*
xpath_expression
);
void
linphone_xml_xpath_context_init_carddav_ns
(
xmlparsing_context_t
*
xml_ctx
);
...
...
coreapi/xml.c
View file @
2dd2ee6e
...
...
@@ -94,7 +94,7 @@ char * linphone_get_xml_text_content(xmlparsing_context_t *xml_ctx, const char *
return
(
char
*
)
text
;
}
const
char
*
linphone_get_xml_attribute_text_content
(
xmlparsing_context_t
*
xml_ctx
,
const
char
*
xpath_expression
,
const
char
*
attribute_name
)
{
char
*
linphone_get_xml_attribute_text_content
(
xmlparsing_context_t
*
xml_ctx
,
const
char
*
xpath_expression
,
const
char
*
attribute_name
)
{
xmlXPathObjectPtr
xpath_obj
;
xmlChar
*
text
=
NULL
;
...
...
@@ -118,10 +118,10 @@ const char * linphone_get_xml_attribute_text_content(xmlparsing_context_t *xml_c
xmlXPathFreeObject
(
xpath_obj
);
}
return
(
const
char
*
)
text
;
return
(
char
*
)
text
;
}
void
linphone_free_xml_text_content
(
const
char
*
text
)
{
void
linphone_free_xml_text_content
(
char
*
text
)
{
xmlFree
((
xmlChar
*
)
text
);
}
...
...
coreapi/xmlrpc.c
View file @
2dd2ee6e
...
...
@@ -196,7 +196,7 @@ static void parse_valid_xml_rpc_response(LinphoneXmlRpcRequest *request, const c
request
->
status
=
LinphoneXmlRpcStatusFailed
;
xml_ctx
->
doc
=
xmlReadDoc
((
const
unsigned
char
*
)
response_body
,
0
,
NULL
,
0
);
if
(
xml_ctx
->
doc
!=
NULL
)
{
const
char
*
response_str
=
NULL
;
char
*
response_str
=
NULL
;
if
(
linphone_create_xml_xpath_context
(
xml_ctx
)
<
0
)
goto
end
;
switch
(
request
->
response
.
type
)
{
case
LinphoneXmlRpcArgInt
:
...
...
tester/message_tester.c
View file @
2dd2ee6e
...
...
@@ -877,6 +877,7 @@ static int enable_lime_for_message_test(LinphoneCoreManager *marie, LinphoneCore
int
ret
=
0
;
char
*
paulineUri
=
NULL
;
char
*
marieUri
=
NULL
;
char
*
tmp
;
if
(
!
linphone_core_lime_available
(
marie
->
lc
)
||
!
linphone_core_lime_available
(
pauline
->
lc
))
{
ms_warning
(
"Lime not available, skiping"
);
...
...
@@ -891,8 +892,12 @@ static int enable_lime_for_message_test(LinphoneCoreManager *marie, LinphoneCore
lp_config_set_int
(
pauline
->
lc
->
config
,
"sip"
,
"zrtp_cache_migration_done"
,
TRUE
);
/* create temporary cache files: setting the database_path will create and initialise the files */
remove
(
bc_tester_file
(
"tmpZIDCacheMarie.sqlite"
));
remove
(
bc_tester_file
(
"tmpZIDCachePauline.sqlite"
));
tmp
=
bc_tester_file
(
"tmpZIDCacheMarie.sqlite"
);
remove
(
tmp
);
bc_free
(
tmp
);
tmp
=
bc_tester_file
(
"tmpZIDCachePauline.sqlite"
);
remove
(
tmp
);
bc_free
(
tmp
);
filepath
=
bc_tester_file
(
"tmpZIDCacheMarie.sqlite"
);
linphone_core_set_zrtp_secrets_file
(
marie
->
lc
,
filepath
);
bc_free
(
filepath
);
...
...
@@ -920,7 +925,8 @@ static int enable_lime_for_message_test(LinphoneCoreManager *marie, LinphoneCore
sqlite3_free
(
errmsg
);
return
-
1
;
}
ms_free
(
paulineUri
);
ms_free
(
marieUri
);
return
0
;
#else
/* SQLITE_STORAGE_ENABLED */
...
...
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