Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/msg.c @ 27906:6ecfc6b9667c
propagate from branch 'im.pidgin.pidgin' (head ca4b6e987b967927b0f8bd001bc33440a6885000)
to branch 'im.pidgin.pidgin.yaz' (head 7a92169e2ac82026d2b2918ed9662c7fd42e3280)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 17 Nov 2008 06:15:33 +0000 |
parents | 7cda79469830 7e8175f9b009 |
children | a959b17ffc57 |
comparison
equal
deleted
inserted
replaced
27905:45ce87f9a07f | 27906:6ecfc6b9667c |
---|---|
193 body_len = len - (tmp - body); | 193 body_len = len - (tmp - body); |
194 /* msg->body_len = msg->msnslp_header.length; */ | 194 /* msg->body_len = msg->msnslp_header.length; */ |
195 | 195 |
196 if (body_len > 0) { | 196 if (body_len > 0) { |
197 msg->body_len = len - (tmp - body); | 197 msg->body_len = len - (tmp - body); |
198 msg->body = g_malloc0(msg->body_len + 1); | 198 msg->body = g_malloc(msg->body_len + 1); |
199 memcpy(msg->body, tmp, msg->body_len); | 199 memcpy(msg->body, tmp, msg->body_len); |
200 msg->body[msg->body_len] = '\0'; | |
200 tmp += body_len; | 201 tmp += body_len; |
201 } | 202 } |
202 } | 203 } |
203 | 204 |
204 void | 205 void |
210 const char *content_type; | 211 const char *content_type; |
211 char *end; | 212 char *end; |
212 char **elems, **cur, **tokens; | 213 char **elems, **cur, **tokens; |
213 | 214 |
214 g_return_if_fail(payload != NULL); | 215 g_return_if_fail(payload != NULL); |
215 tmp_base = tmp = g_malloc0(payload_len + 1); | 216 tmp_base = tmp = g_malloc(payload_len + 1); |
216 memcpy(tmp_base, payload, payload_len); | 217 memcpy(tmp_base, payload, payload_len); |
218 tmp_base[payload_len] = '\0'; | |
217 | 219 |
218 /* Parse the attributes. */ | 220 /* Parse the attributes. */ |
219 end = strstr(tmp, body_dem); | 221 end = strstr(tmp, body_dem); |
220 /* TODO? some clients use \r delimiters instead of \r\n, the official client | 222 /* TODO? some clients use \r delimiters instead of \r\n, the official client |
221 * doesn't send such messages, but does handle receiving them. We'll just | 223 * doesn't send such messages, but does handle receiving them. We'll just |
309 | 311 |
310 /* Import the body. */ | 312 /* Import the body. */ |
311 if (body_len > 0) { | 313 if (body_len > 0) { |
312 msg->body_len = body_len; | 314 msg->body_len = body_len; |
313 g_free(msg->body); | 315 g_free(msg->body); |
314 msg->body = g_malloc0(msg->body_len + 1); | 316 msg->body = g_malloc(msg->body_len + 1); |
315 memcpy(msg->body, tmp, msg->body_len); | 317 memcpy(msg->body, tmp, msg->body_len); |
318 msg->body[msg->body_len] = '\0'; | |
316 tmp += body_len; | 319 tmp += body_len; |
317 } | 320 } |
318 | 321 |
319 /* Import the footer. */ | 322 /* Import the footer. */ |
320 if (body_len >= 0) { | 323 if (body_len >= 0) { |
326 else | 329 else |
327 { | 330 { |
328 if (payload_len - (tmp - tmp_base) > 0) { | 331 if (payload_len - (tmp - tmp_base) > 0) { |
329 msg->body_len = payload_len - (tmp - tmp_base); | 332 msg->body_len = payload_len - (tmp - tmp_base); |
330 g_free(msg->body); | 333 g_free(msg->body); |
331 msg->body = g_malloc0(msg->body_len + 1); | 334 msg->body = g_malloc(msg->body_len + 1); |
332 memcpy(msg->body, tmp, msg->body_len); | 335 memcpy(msg->body, tmp, msg->body_len); |
336 msg->body[msg->body_len] = '\0'; | |
333 } | 337 } |
334 } | 338 } |
335 | 339 |
336 g_free(tmp_base); | 340 g_free(tmp_base); |
337 } | 341 } |
524 if (msg->body != NULL) | 528 if (msg->body != NULL) |
525 g_free(msg->body); | 529 g_free(msg->body); |
526 | 530 |
527 if (data != NULL && len > 0) | 531 if (data != NULL && len > 0) |
528 { | 532 { |
529 msg->body = g_malloc0(len + 1); | 533 msg->body = g_malloc(len + 1); |
530 memcpy(msg->body, data, len); | 534 memcpy(msg->body, data, len); |
535 msg->body[len] = '\0'; | |
531 msg->body_len = len; | 536 msg->body_len = len; |
532 } | 537 } |
533 else | 538 else |
534 { | 539 { |
535 msg->body = NULL; | 540 msg->body = NULL; |