comparison libpurple/protocols/msn/slp.c @ 30546:fc93bc1a546f

So, elb informs me this is probably not safe on non-x86 architectures. Swapping the types of these two should hopefully avoid a non-aligned write.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 28 May 2010 23:16:57 +0000
parents 7f564cf26ea3
children 76049fde7ad2 562498203fe8
comparison
equal deleted inserted replaced
30544:ef7303c25751 30546:fc93bc1a546f
286 286
287 nonce = get_token(content, "Hashed-Nonce: {", "}\r\n"); 287 nonce = get_token(content, "Hashed-Nonce: {", "}\r\n");
288 if (nonce) { 288 if (nonce) {
289 *ntype = DC_NONCE_SHA1; 289 *ntype = DC_NONCE_SHA1;
290 } else { 290 } else {
291 guint32 n1, n5; 291 guint32 n1, n6;
292 guint16 n2, n3, n4, n6; 292 guint16 n2, n3, n4, n5;
293 nonce = get_token(content, "Nonce: {", "}\r\n"); 293 nonce = get_token(content, "Nonce: {", "}\r\n");
294 if (nonce 294 if (nonce
295 && sscanf(nonce, "%08x-%04hx-%04hx-%04hx-%08x%04hx", 295 && sscanf(nonce, "%08x-%04hx-%04hx-%04hx-%04hx%08x",
296 &n1, &n2, &n3, &n4, &n5, &n6) == 6) { 296 &n1, &n2, &n3, &n4, &n5, &n6) == 6) {
297 *ntype = DC_NONCE_PLAIN; 297 *ntype = DC_NONCE_PLAIN;
298 g_free(nonce); 298 g_free(nonce);
299 nonce = g_malloc(16); 299 nonce = g_malloc(16);
300 *(guint32 *)(nonce + 0) = GUINT32_TO_LE(n1); 300 *(guint32 *)(nonce + 0) = GUINT32_TO_LE(n1);
301 *(guint16 *)(nonce + 4) = GUINT16_TO_LE(n2); 301 *(guint16 *)(nonce + 4) = GUINT16_TO_LE(n2);
302 *(guint16 *)(nonce + 6) = GUINT16_TO_LE(n3); 302 *(guint16 *)(nonce + 6) = GUINT16_TO_LE(n3);
303 *(guint16 *)(nonce + 8) = GUINT16_TO_BE(n4); 303 *(guint16 *)(nonce + 8) = GUINT16_TO_BE(n4);
304 *(guint32 *)(nonce + 10) = GUINT32_TO_BE(n5); 304 *(guint16 *)(nonce + 10) = GUINT16_TO_BE(n5);
305 *(guint16 *)(nonce + 14) = GUINT16_TO_BE(n6); 305 *(guint32 *)(nonce + 12) = GUINT32_TO_BE(n6);
306 } else { 306 } else {
307 /* Invalid nonce, so ignore request */ 307 /* Invalid nonce, so ignore request */
308 g_free(nonce); 308 g_free(nonce);
309 nonce = NULL; 309 nonce = NULL;
310 } 310 }