pidgin/pidgin

Fix some issues scanbuild found in the xmpp protocol plugin
release-2.x.y
2021-06-02, Gary Kramlich
814b934cf5b7
Parents 128a40bc6e88
Children f484a9317ad7
Fix some issues scanbuild found in the xmpp protocol plugin

Testing Done:
Verified that scanbuild no longer detected the errors.

Reviewed at https://reviews.imfreedom.org/r/711/
--- a/libpurple/protocols/jabber/auth_scram.c Wed Jun 02 04:17:25 2021 -0500
+++ b/libpurple/protocols/jabber/auth_scram.c Wed Jun 02 17:59:31 2021 -0500
@@ -142,6 +142,13 @@
guchar *salted_password;
guchar *client_key, *stored_key, *client_signature, *server_key;
+ salted_password = jabber_scram_hi(data->hash, pass, salt, iterations);
+ memset(pass->str, 0, pass->allocated_len);
+ g_string_free(pass, TRUE);
+
+ if (!salted_password)
+ return FALSE;
+
client_key = g_new0(guchar, hash_len);
stored_key = g_new0(guchar, hash_len);
client_signature = g_new0(guchar, hash_len);
@@ -152,14 +159,6 @@
data->server_signature = g_string_sized_new(hash_len);
data->server_signature->len = hash_len;
- salted_password = jabber_scram_hi(data->hash, pass, salt, iterations);
-
- memset(pass->str, 0, pass->allocated_len);
- g_string_free(pass, TRUE);
-
- if (!salted_password)
- return FALSE;
-
/* client_key = HMAC(salted_password, "Client Key") */
jabber_scram_hmac(data->hash, client_key, salted_password, "Client Key");
/* server_key = HMAC(salted_password, "Server Key") */
--- a/libpurple/protocols/jabber/google/google_session.c Wed Jun 02 04:17:25 2021 -0500
+++ b/libpurple/protocols/jabber/google/google_session.c Wed Jun 02 17:59:31 2021 -0500
@@ -562,6 +562,7 @@
(GoogleAVSessionData *) session->session_data;
if (session->state != UNINIT) {
+ google_session_destroy(session);
purple_debug_error("jabber", "Received initiate for active session.\n");
return FALSE;
}
@@ -574,6 +575,7 @@
else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_VIDEO))
session_data->video = TRUE;
else {
+ google_session_destroy(session);
purple_debug_error("jabber", "Received initiate with "
"invalid namespace %s.\n", xmlns);
return FALSE;
--- a/libpurple/protocols/jabber/presence.c Wed Jun 02 04:17:25 2021 -0500
+++ b/libpurple/protocols/jabber/presence.c Wed Jun 02 17:59:31 2021 -0500
@@ -339,7 +339,7 @@
}
/* if we are idle and not offline, include idle */
- if (js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) {
+ if (js != NULL && js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) {
xmlnode *query = xmlnode_new_child(presence, "query");
gchar seconds[10];
g_snprintf(seconds, 10, "%d", (int) (time(NULL) - js->idle));
@@ -350,7 +350,10 @@
/* JEP-0115 */
/* calculate hash */
- jabber_caps_calculate_own_hash(js);
+ if(js != NULL) {
+ jabber_caps_calculate_own_hash(js);
+ }
+
/* create xml */
c = xmlnode_new_child(presence, "c");
xmlnode_set_namespace(c, "http://jabber.org/protocol/caps");