/pidgin/main: 270d16117280: Prevent (another) NULL pointer deref...
Daniel Atallah
datallah at pidgin.im
Sun Feb 24 23:16:14 EST 2013
Changeset: 270d161172808ef704c286f5516ecd42d56a0793
Author: Daniel Atallah <datallah at pidgin.im>
Date: 2013-02-24 23:16 -0500
Branch: release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/270d16117280
Description:
Prevent (another) NULL pointer deref when initating a rtp session with an unrecognized resource
diffstat:
libpurple/protocols/jabber/jabber.c | 55 ++++++++++++++++++------------------
1 files changed, 28 insertions(+), 27 deletions(-)
diffs (83 lines):
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -3293,7 +3293,7 @@ jabber_initiate_media(PurpleAccount *acc
purple_account_get_connection(account)->proto_data;
JabberBuddy *jb;
JabberBuddyResource *jbr = NULL;
- char *resource;
+ char *resource = NULL;
if (!js) {
purple_debug_error("jabber",
@@ -3302,43 +3302,44 @@ jabber_initiate_media(PurpleAccount *acc
}
- if((resource = jabber_get_resource(who)) != NULL) {
+ jb = jabber_buddy_find(js, who, FALSE);
+
+ if(!jb || !jb->resources ||
+ (((resource = jabber_get_resource(who)) != NULL)
+ && (jbr = jabber_buddy_find_resource(jb, resource)) == NULL)) {
+ /* no resources online, we're trying to initiate with someone
+ * whose presence we're not subscribed to, or
+ * someone who is offline. Let's inform the user */
+ char *msg;
+
+ if(!jb) {
+ msg = g_strdup_printf(_("Unable to initiate media with %s: invalid JID"), who);
+ } else if(jb->subscription & JABBER_SUB_TO && !jb->resources) {
+ msg = g_strdup_printf(_("Unable to initiate media with %s: user is not online"), who);
+ } else if(resource) {
+ msg = g_strdup_printf(_("Unable to initiate media with %s: resource is not online"), who);
+ } else {
+ msg = g_strdup_printf(_("Unable to initiate media with %s: not subscribed to user presence"), who);
+ }
+
+ purple_notify_error(account, _("Media Initiation Failed"),
+ _("Media Initiation Failed"), msg);
+ g_free(msg);
+ g_free(resource);
+ return FALSE;
+ } else if(jbr != NULL) {
/* they've specified a resource, no need to ask or
* default or anything, just do it */
- jb = jabber_buddy_find(js, who, FALSE);
- jbr = jabber_buddy_find_resource(jb, resource);
g_free(resource);
if (type & PURPLE_MEDIA_AUDIO &&
!jabber_resource_has_capability(jbr,
- JINGLE_APP_RTP_SUPPORT_AUDIO) &&
+ JINGLE_APP_RTP_SUPPORT_AUDIO) &&
jabber_resource_has_capability(jbr, NS_GOOGLE_VOICE))
return jabber_google_session_initiate(js, who, type);
else
return jingle_rtp_initiate_media(js, who, type);
- }
-
- jb = jabber_buddy_find(js, who, FALSE);
-
- if(!jb || !jb->resources) {
- /* no resources online, we're trying to initiate with someone
- * whose presence we're not subscribed to, or
- * someone who is offline. Let's inform the user */
- char *msg;
-
- if(!jb) {
- msg = g_strdup_printf(_("Unable to initiate media with %s: invalid JID"), who);
- } else if(jb->subscription & JABBER_SUB_TO) {
- msg = g_strdup_printf(_("Unable to initiate media with %s: user is not online"), who);
- } else {
- msg = g_strdup_printf(_("Unable to initiate media with %s: not subscribed to user presence"), who);
- }
-
- purple_notify_error(account, _("Media Initiation Failed"),
- _("Media Initiation Failed"), msg);
- g_free(msg);
- return FALSE;
} else if(!jb->resources->next) {
/* only 1 resource online (probably our most common case)
* so no need to ask who to initiate with */
More information about the Commits
mailing list