Mercurial > pidgin.yaz
diff src/protocols/msn/msg.c @ 11235:5ea38c98ff30
[gaim-migrate @ 13380]
Patch 1256826 from Federico Schwindt to ensure msg->body is always nul
terminated (even though strictly it shouldn't need to be, it's safer
like this). Plus a fix by me for one case where we were assuming it was
already nul terminated.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Thu, 11 Aug 2005 19:25:48 +0000 |
parents | 0c9e936c154b |
children | 95fa774d216d |
line wrap: on
line diff
--- a/src/protocols/msn/msg.c Thu Aug 11 15:53:09 2005 +0000 +++ b/src/protocols/msn/msg.c Thu Aug 11 19:25:48 2005 +0000 @@ -187,7 +187,8 @@ if (body_len > 0) { msg->body_len = len - (tmp - body); - msg->body = g_memdup(tmp, msg->body_len); + msg->body = g_malloc0(msg->body_len + 1); + memcpy(msg->body, tmp, msg->body_len); tmp += body_len; } } @@ -300,7 +301,8 @@ /* Import the body. */ if (body_len > 0) { msg->body_len = body_len; - msg->body = g_memdup(tmp, msg->body_len); + msg->body = g_malloc0(msg->body_len + 1); + memcpy(msg->body, tmp, msg->body_len); tmp += body_len; } @@ -315,7 +317,8 @@ { if (payload_len - (tmp - tmp_base) > 0) { msg->body_len = payload_len - (tmp - tmp_base); - msg->body = g_memdup(tmp, msg->body_len); + msg->body = g_malloc0(msg->body_len + 1); + memcpy(msg->body, tmp, msg->body_len); } } @@ -511,7 +514,8 @@ if (data != NULL && len > 0) { - msg->body = g_memdup(data, len); + msg->body = g_malloc0(len + 1); + memcpy(msg->body, data, len); msg->body_len = len; } else