- Security Audit Report : Patch for Bug No. 5.2.

File c_micasad/lib/communication/UnixIPCClientChannel.cs
  Determine buffer size needed based on the amount of data being sent.
This commit is contained in:
Jim Norman 2006-04-12 15:15:13 +00:00
parent 53c962844c
commit 6398d22745
2 changed files with 39 additions and 15 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Apr 12 09:13:10 MST 2006 - jnorman@novell.com
- Security Audit Report : Patch for Bug No. 5.2.
File c_micasad/lib/communication/UnixIPCClientChannel.cs
Determine buffer size needed based on the amount of data being sent.
-------------------------------------------------------------------
Mon Apr 10 09:41:10 MST 2006 - jnorman@novell.com
- Bug 154548. Fix to display firefox secrets in CASAManager.

View File

@ -25,6 +25,7 @@ using System.Net;
using System.IO;
using System.Net.Sockets;
using Mono.Unix;
using System.Text;
namespace Novell.CASA.MiCasa.Communication
{
@ -95,34 +96,51 @@ namespace Novell.CASA.MiCasa.Communication
byte[] msgIdBytes = new byte[2];
bytesRecvd = mSocket.Receive(msgIdBytes);
if( 0 == bytesRecvd )
if( 0 == bytesRecvd )
{
return null;
}
byte[] msgLenBytes = new byte[4];
bytesRecvd = mSocket.Receive(msgLenBytes);
if( 0 == bytesRecvd )
if( 0 == bytesRecvd )
{
return null;
}
uint msgLen = BitConverter.ToUInt32(msgLenBytes,0);
if( msgLen > 6 )
if( msgLen > 6 )
{
byte[] buf = new byte[msgLen - 6];
bytesRecvd = mSocket.Receive (buf);
if( 0 == bytesRecvd )
{
return null;
}
returnBuffer = new byte[msgLen];
System.Text.Encoding encoding = System.Text.Encoding.ASCII;
byte[] buf = null;
int bytesAvailable;
int totalBytes = 0;
int msgLencount = 0;
string bufstring = null;
byte[] temp = null;
while(totalBytes<(msgLen-6))
{
bytesAvailable = mSocket.Available;
if( 0 == bytesAvailable)
{
break;
}
buf = new byte[bytesAvailable];
bytesRecvd = mSocket.Receive (buf);
bufstring = bufstring + encoding.GetString(buf); //keep buffering in a string
totalBytes = totalBytes + bytesAvailable;
}
if(totalBytes==0)
return null;
byte[] finalbuf = encoding.GetBytes(bufstring);//finally, convert the string to a byte array of size 'totalBytes'
int returnBufferLen = msgIdBytes.Length+msgLenBytes.Length+totalBytes;
returnBuffer = new byte[returnBufferLen];
Array.Copy(msgIdBytes,returnBuffer,2);
Array.Copy(msgLenBytes,0,returnBuffer,2,4);
Array.Copy(buf,0,returnBuffer,6,buf.Length);
return returnBuffer;
Array.Copy(finalbuf,0,returnBuffer,6,finalbuf.Length);
return returnBuffer;
}
else
else
{
returnBuffer = new byte[6];
Array.Copy(msgIdBytes,returnBuffer,2);
@ -142,7 +160,7 @@ namespace Novell.CASA.MiCasa.Communication
try
{
mSocket.Send(buf);
//Console.WriteLine("Bytes written = " + buf.Length);
//Console.WriteLine("Bytes written = " + buf.Length);
return buf.Length;
}
catch (Exception e)