comparison mcabber/mcabber/xmpp.c @ 2195:40ddaebeb81e

PGP: Add a memory allocation check and compilation directives
author Mikael Berthe <mikael@lilotux.net>
date Wed, 07 Oct 2015 21:55:51 +0200
parents f4c00c72b27d
children 189abf03ef24
comparison
equal deleted inserted replaced
2194:f4c00c72b27d 2195:40ddaebeb81e
383 if (!key && res_pgpdata) 383 if (!key && res_pgpdata)
384 key = res_pgpdata->sign_keyid; 384 key = res_pgpdata->sign_keyid;
385 if (key) { 385 if (key) {
386 int nkeys = 1; 386 int nkeys = 1;
387 const char *keys[] = { key, 0 }; 387 const char *keys[] = { key, 0 };
388 if (carbons_enabled()) { 388 if (carbons_enabled())
389 keys[1] = gpg_get_private_key_id(); 389 keys[nkeys++] = gpg_get_private_key_id();
390 nkeys++;
391 }
392 enc = gpg_encrypt(text, keys, nkeys); 390 enc = gpg_encrypt(text, keys, nkeys);
393 } 391 }
394 if (!enc && force) { 392 if (!enc && force) {
395 if (encrypted) 393 if (encrypted)
396 *encrypted = -1; 394 *encrypted = -1;
1139 handle_state_events(from, res, x); 1137 handle_state_events(from, res, x);
1140 1138
1141 scr_LogPrint(LPRINT_DEBUG, "Received incoming carbon from <%s>", from); 1139 scr_LogPrint(LPRINT_DEBUG, "Received incoming carbon from <%s>", from);
1142 1140
1143 } else if (!g_strcmp0(carbon_name, "sent")) { 1141 } else if (!g_strcmp0(carbon_name, "sent")) {
1142 #ifdef HAVE_GPGME
1143 char *decrypted_pgp = NULL;
1144 #endif
1144 guint encrypted = 0; 1145 guint encrypted = 0;
1145 char *decrypted_pgp = NULL;
1146 const char *to= lm_message_node_get_attribute(x, "to"); 1146 const char *to= lm_message_node_get_attribute(x, "to");
1147 if (!to) { 1147 if (!to) {
1148 scr_LogPrint(LPRINT_LOGNORM, "Malformed carbon copy!"); 1148 scr_LogPrint(LPRINT_LOGNORM, "Malformed carbon copy!");
1149 goto handle_messages_return; 1149 goto handle_messages_return;
1150 } 1150 }
1172 1172
1173 if (body && *body) 1173 if (body && *body)
1174 hk_message_out(bjid, NULL, timestamp, body, encrypted, TRUE, NULL); 1174 hk_message_out(bjid, NULL, timestamp, body, encrypted, TRUE, NULL);
1175 1175
1176 scr_LogPrint(LPRINT_DEBUG, "Received outgoing carbon for <%s>", to); 1176 scr_LogPrint(LPRINT_DEBUG, "Received outgoing carbon for <%s>", to);
1177 #ifdef HAVE_GPGME
1177 g_free(decrypted_pgp); 1178 g_free(decrypted_pgp);
1179 #endif
1178 goto handle_messages_return; 1180 goto handle_messages_return;
1179 } 1181 }
1180 } else { // Not a Carbon 1182 } else { // Not a Carbon
1181 ns_signed = lm_message_node_find_xmlns(m->node, NS_SIGNED); 1183 ns_signed = lm_message_node_find_xmlns(m->node, NS_SIGNED);
1182 } 1184 }