mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 16:06:22 +00:00
stanza: guard mallocs
If this happens we have more serious problems :-) But anyways..
This commit is contained in:
@@ -288,12 +288,14 @@ void
|
|||||||
iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata)
|
iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata)
|
||||||
{
|
{
|
||||||
ProfIqHandler* handler = malloc(sizeof(ProfIqHandler));
|
ProfIqHandler* handler = malloc(sizeof(ProfIqHandler));
|
||||||
|
if (handler) {
|
||||||
handler->func = func;
|
handler->func = func;
|
||||||
handler->free_func = free_func;
|
handler->free_func = free_func;
|
||||||
handler->userdata = userdata;
|
handler->userdata = userdata;
|
||||||
|
|
||||||
g_hash_table_insert(id_handlers, strdup(id), handler);
|
g_hash_table_insert(id_handlers, strdup(id), handler);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
iq_autoping_timer_cancel(void)
|
iq_autoping_timer_cancel(void)
|
||||||
@@ -481,17 +483,19 @@ iq_room_info_request(const char* const room, gboolean display_result)
|
|||||||
xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, room, NULL);
|
xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, id, room, NULL);
|
||||||
|
|
||||||
ProfRoomInfoData* cb_data = malloc(sizeof(ProfRoomInfoData));
|
ProfRoomInfoData* cb_data = malloc(sizeof(ProfRoomInfoData));
|
||||||
|
if (cb_data) {
|
||||||
cb_data->room = strdup(room);
|
cb_data->room = strdup(room);
|
||||||
cb_data->display = display_result;
|
cb_data->display = display_result;
|
||||||
|
|
||||||
iq_id_handler_add(id, _room_info_response_id_handler, (ProfIqFreeCallback)_iq_free_room_data, cb_data);
|
iq_id_handler_add(id, _room_info_response_id_handler, (ProfIqFreeCallback)_iq_free_room_data, cb_data);
|
||||||
|
|
||||||
free(id);
|
|
||||||
|
|
||||||
iq_send_stanza(iq);
|
iq_send_stanza(iq);
|
||||||
xmpp_stanza_release(iq);
|
xmpp_stanza_release(iq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(id);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
iq_send_caps_request_for_jid(const char* const to, const char* const id,
|
iq_send_caps_request_for_jid(const char* const to, const char* const id,
|
||||||
const char* const node, const char* const ver)
|
const char* const node, const char* const ver)
|
||||||
@@ -667,6 +671,7 @@ iq_room_affiliation_list(const char* const room, char* affiliation, bool show_ui
|
|||||||
const char* id = xmpp_stanza_get_id(iq);
|
const char* id = xmpp_stanza_get_id(iq);
|
||||||
|
|
||||||
ProfAffiliationList* affiliation_list = malloc(sizeof(ProfAffiliationList));
|
ProfAffiliationList* affiliation_list = malloc(sizeof(ProfAffiliationList));
|
||||||
|
if (affiliation_list) {
|
||||||
affiliation_list->affiliation = strdup(affiliation);
|
affiliation_list->affiliation = strdup(affiliation);
|
||||||
affiliation_list->show_ui_message = show_ui_message;
|
affiliation_list->show_ui_message = show_ui_message;
|
||||||
|
|
||||||
@@ -675,6 +680,7 @@ iq_room_affiliation_list(const char* const room, char* affiliation, bool show_ui
|
|||||||
iq_send_stanza(iq);
|
iq_send_stanza(iq);
|
||||||
xmpp_stanza_release(iq);
|
xmpp_stanza_release(iq);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
iq_room_kick_occupant(const char* const room, const char* const nick, const char* const reason)
|
iq_room_kick_occupant(const char* const room, const char* const nick, const char* const reason)
|
||||||
@@ -699,6 +705,7 @@ iq_room_affiliation_set(const char* const room, const char* const jid, char* aff
|
|||||||
const char* id = xmpp_stanza_get_id(iq);
|
const char* id = xmpp_stanza_get_id(iq);
|
||||||
|
|
||||||
ProfPrivilegeSet* affiliation_set = malloc(sizeof(struct privilege_set_t));
|
ProfPrivilegeSet* affiliation_set = malloc(sizeof(struct privilege_set_t));
|
||||||
|
if (affiliation_set) {
|
||||||
affiliation_set->item = strdup(jid);
|
affiliation_set->item = strdup(jid);
|
||||||
affiliation_set->privilege = strdup(affiliation);
|
affiliation_set->privilege = strdup(affiliation);
|
||||||
|
|
||||||
@@ -707,6 +714,7 @@ iq_room_affiliation_set(const char* const room, const char* const jid, char* aff
|
|||||||
iq_send_stanza(iq);
|
iq_send_stanza(iq);
|
||||||
xmpp_stanza_release(iq);
|
xmpp_stanza_release(iq);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
iq_room_role_set(const char* const room, const char* const nick, char* role,
|
iq_room_role_set(const char* const room, const char* const nick, char* role,
|
||||||
@@ -718,6 +726,7 @@ iq_room_role_set(const char* const room, const char* const nick, char* role,
|
|||||||
const char* id = xmpp_stanza_get_id(iq);
|
const char* id = xmpp_stanza_get_id(iq);
|
||||||
|
|
||||||
struct privilege_set_t* role_set = malloc(sizeof(ProfPrivilegeSet));
|
struct privilege_set_t* role_set = malloc(sizeof(ProfPrivilegeSet));
|
||||||
|
if (role_set) {
|
||||||
role_set->item = strdup(nick);
|
role_set->item = strdup(nick);
|
||||||
role_set->privilege = strdup(role);
|
role_set->privilege = strdup(role);
|
||||||
|
|
||||||
@@ -726,6 +735,7 @@ iq_room_role_set(const char* const room, const char* const nick, char* role,
|
|||||||
iq_send_stanza(iq);
|
iq_send_stanza(iq);
|
||||||
xmpp_stanza_release(iq);
|
xmpp_stanza_release(iq);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
iq_room_role_list(const char* const room, char* role)
|
iq_room_role_list(const char* const room, char* role)
|
||||||
@@ -2162,6 +2172,7 @@ _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata
|
|||||||
if (name || category || type) {
|
if (name || category || type) {
|
||||||
DiscoIdentity* identity = malloc(sizeof(struct disco_identity_t));
|
DiscoIdentity* identity = malloc(sizeof(struct disco_identity_t));
|
||||||
|
|
||||||
|
if (identity) {
|
||||||
if (name) {
|
if (name) {
|
||||||
identity->name = strdup(name);
|
identity->name = strdup(name);
|
||||||
ProfMucWin* mucwin = wins_get_muc(cb_data->room);
|
ProfMucWin* mucwin = wins_get_muc(cb_data->room);
|
||||||
@@ -2185,6 +2196,7 @@ _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata
|
|||||||
identities = g_slist_append(identities, identity);
|
identities = g_slist_append(identities, identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
child = xmpp_stanza_get_next(child);
|
child = xmpp_stanza_get_next(child);
|
||||||
}
|
}
|
||||||
@@ -2309,6 +2321,7 @@ _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdat
|
|||||||
if (name || category || type) {
|
if (name || category || type) {
|
||||||
DiscoIdentity* identity = malloc(sizeof(struct disco_identity_t));
|
DiscoIdentity* identity = malloc(sizeof(struct disco_identity_t));
|
||||||
|
|
||||||
|
if (identity) {
|
||||||
if (name) {
|
if (name) {
|
||||||
identity->name = strdup(name);
|
identity->name = strdup(name);
|
||||||
} else {
|
} else {
|
||||||
@@ -2328,6 +2341,7 @@ _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdat
|
|||||||
identities = g_slist_append(identities, identity);
|
identities = g_slist_append(identities, identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
child = xmpp_stanza_get_next(child);
|
child = xmpp_stanza_get_next(child);
|
||||||
}
|
}
|
||||||
@@ -2491,6 +2505,7 @@ _disco_items_result_handler(xmpp_stanza_t* const stanza)
|
|||||||
const char* item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
const char* item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||||
if (item_jid) {
|
if (item_jid) {
|
||||||
DiscoItem* item = malloc(sizeof(struct disco_item_t));
|
DiscoItem* item = malloc(sizeof(struct disco_item_t));
|
||||||
|
if (item) {
|
||||||
item->jid = strdup(item_jid);
|
item->jid = strdup(item_jid);
|
||||||
const char* item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
|
const char* item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
|
||||||
if (item_name) {
|
if (item_name) {
|
||||||
@@ -2501,6 +2516,7 @@ _disco_items_result_handler(xmpp_stanza_t* const stanza)
|
|||||||
items = g_slist_append(items, item);
|
items = g_slist_append(items, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
child = xmpp_stanza_get_next(child);
|
child = xmpp_stanza_get_next(child);
|
||||||
}
|
}
|
||||||
@@ -2578,10 +2594,12 @@ iq_mam_request(ProfChatWin* win)
|
|||||||
xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, win->barejid, datestr, NULL);
|
xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, win->barejid, datestr, NULL);
|
||||||
|
|
||||||
MamRsmUserdata* data = malloc(sizeof(MamRsmUserdata));
|
MamRsmUserdata* data = malloc(sizeof(MamRsmUserdata));
|
||||||
|
if (data) {
|
||||||
data->datestr = strdup(datestr);
|
data->datestr = strdup(datestr);
|
||||||
data->barejid = strdup(win->barejid);
|
data->barejid = strdup(win->barejid);
|
||||||
|
|
||||||
iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, NULL, data);
|
iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, NULL, data);
|
||||||
|
}
|
||||||
|
|
||||||
g_free(datestr);
|
g_free(datestr);
|
||||||
g_date_time_unref(timestamp);
|
g_date_time_unref(timestamp);
|
||||||
|
|||||||
Reference in New Issue
Block a user