From dbf45ad4294a59c050982b5a417fe86272026454 Mon Sep 17 00:00:00 2001
From: Steven Bennetts <steve@lindenlab.com>
Date: Sat, 13 Jan 2007 00:06:17 +0000
Subject: [PATCH] merge -r 56266 release-candidate merge -r 56301
 release-candidate Fixes for llxfer.cpp and llaudiodecodemgr.cpp (asset upload
 truncation bug) llxfer.cpp got missed somehow the first time round, grr!

---
 indra/llmessage/llxfer.cpp | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/indra/llmessage/llxfer.cpp b/indra/llmessage/llxfer.cpp
index 154696eb4e3..f43a8a56ffd 100644
--- a/indra/llmessage/llxfer.cpp
+++ b/indra/llmessage/llxfer.cpp
@@ -190,19 +190,26 @@ void LLXfer::sendPacket(S32 packet_num)
 	if (packet_num)
 	{ 
 		num_copy = llmin(fdata_size, (S32)sizeof(fdata_buf));
-		num_copy = llmin(num_copy, (S32)(sizeof(mBuffer) - desired_read_position));
+		num_copy = llmin(num_copy, (S32)(mBufferLength - desired_read_position));
 		if (num_copy > 0)
 		{
 			memcpy(fdata_buf,&mBuffer[desired_read_position],num_copy);
 		}
 	}
-	else  // if we're the first packet, encode size as an additional S32 at start of data
-	{	 
+	else  
+	{
+		// if we're the first packet, encode size as an additional S32
+		// at start of data.
 		num_copy = llmin(fdata_size, (S32)(sizeof(fdata_buf)-sizeof(S32)));
-		num_copy = llmin(num_copy, (S32)(sizeof(mBuffer) - desired_read_position));
+		num_copy = llmin(
+			num_copy,
+			(S32)(mBufferLength - desired_read_position));
 		if (num_copy > 0)
 		{
-			memcpy(fdata_buf+sizeof(S32),&mBuffer[desired_read_position],fdata_size);
+			memcpy(
+				fdata_buf + sizeof(S32),
+				&mBuffer[desired_read_position],
+				num_copy);
 		}
 		fdata_size += sizeof(S32);
 		htonmemcpy(fdata_buf,&mXferSize, MVT_S32, sizeof(S32));
-- 
GitLab