comparison libpurple/protocols/jabber/presence.c @ 24693:61e0924de04a

Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum when bytes in the checksum start with 0 (for example, 430902... would become 4392...). Refs #7734, which has a second patch needing more detailed review. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author Paul Aurich <paul@darkrain42.org>
date Thu, 11 Dec 2008 08:08:02 +0000
parents 10ab5441572f
children bba38f03085d
comparison
equal deleted inserted replaced
24692:915b1cafa3d1 24693:61e0924de04a
19 * 19 *
20 */ 20 */
21 #include "internal.h" 21 #include "internal.h"
22 22
23 #include "account.h" 23 #include "account.h"
24 #include "cipher.h"
25 #include "conversation.h" 24 #include "conversation.h"
26 #include "debug.h" 25 #include "debug.h"
27 #include "notify.h" 26 #include "notify.h"
28 #include "request.h" 27 #include "request.h"
29 #include "server.h" 28 #include "server.h"
347 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { 346 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
348 if((photo = xmlnode_get_child(vcard, "PHOTO")) && 347 if((photo = xmlnode_get_child(vcard, "PHOTO")) &&
349 (( (binval = xmlnode_get_child(photo, "BINVAL")) && 348 (( (binval = xmlnode_get_child(photo, "BINVAL")) &&
350 (text = xmlnode_get_data(binval))) || 349 (text = xmlnode_get_data(binval))) ||
351 (text = xmlnode_get_data(photo)))) { 350 (text = xmlnode_get_data(photo)))) {
352 unsigned char hashval[20]; 351 char *hash;
353 char hash[41], *p;
354 int i;
355 352
356 data = purple_base64_decode(text, &size); 353 data = purple_base64_decode(text, &size);
357 354 hash = jabber_calculate_data_sha1sum(data, size);
358 purple_cipher_digest_region("sha1", data, size,
359 sizeof(hashval), hashval, NULL);
360 p = hash;
361 for(i=0; i<20; i++, p+=2)
362 snprintf(p, 3, "%02x", hashval[i]);
363
364 purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash); 355 purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash);
356 g_free(hash);
365 g_free(text); 357 g_free(text);
366 } 358 }
367 } 359 }
368 } 360 }
369 361