fix(net10): use exact stream reads and modern X509CertificateLoader
This commit is contained in:
1 parent
e9f2e93740
commit
6f0e46a25a
6 files changed
+25
-15
No files matched your search
@@ -217,7 +217,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
try
|
||||
{
|
||||
m_cert = new X509Certificate2(CPath, CPass);
|
||||
m_cert = X509CertificateLoader.LoadPkcs12FromFile(CPath, CPass);
|
||||
X509Extension ext = m_cert.Extensions["2.5.29.17"];
|
||||
if(ext != null)
|
||||
{
|
||||
|
||||
@@ -235,7 +235,17 @@ namespace OSHttpServer
|
||||
}
|
||||
|
||||
var buffer = new byte[m_body.Length];
|
||||
m_body.Read(buffer, 0, (int)m_body.Length);
|
||||
// Preserve the original request stream position while cloning its full body.
|
||||
long originalPosition = m_body.Position;
|
||||
try
|
||||
{
|
||||
m_body.Position = 0;
|
||||
m_body.ReadExactly(buffer);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_body.Position = originalPosition;
|
||||
}
|
||||
request.Body = new MemoryStream();
|
||||
request.Body.Write(buffer, 0, buffer.Length);
|
||||
request.Body.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
@@ -2581,7 +2581,7 @@ namespace OpenSim.Framework
|
||||
|
||||
memory.Position = 0;
|
||||
using GZipStream decompressor = new(memory, CompressionMode.Decompress);
|
||||
decompressor.Read(buffer, 0, buffer.Length);
|
||||
decompressor.ReadExactly(buffer);
|
||||
|
||||
return Util.UTF8.GetString(buffer);
|
||||
}
|
||||
@@ -2884,7 +2884,7 @@ namespace OpenSim.Framework
|
||||
public static OSDMap GetOSDMap(Stream stream, int length)
|
||||
{
|
||||
byte[] data = new byte[length];
|
||||
stream.Read(data, 0, length);
|
||||
stream.ReadExactly(data);
|
||||
string strdata = Util.UTF8.GetString(data);
|
||||
OSDMap args;
|
||||
OSD buffer;
|
||||
|
||||
@@ -1426,7 +1426,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||
using(FileStream input = new FileStream(Util.dataDir() + "/terrain.raw",FileMode.Open))
|
||||
{
|
||||
bdata = new byte[input.Length];
|
||||
input.Read(bdata, 0, (int)input.Length);
|
||||
input.ReadExactly(bdata);
|
||||
}
|
||||
if(bdata == null || bdata.Length == 0)
|
||||
{
|
||||
|
||||
@@ -398,7 +398,6 @@ namespace OpenSim.Region.DataSnapshot
|
||||
#region External data services
|
||||
private void NotifyDataServices(string servicesStr, string serviceName)
|
||||
{
|
||||
Stream reply = null;
|
||||
string delimStr = ";";
|
||||
char [] delimiter = delimStr.ToCharArray();
|
||||
|
||||
@@ -416,10 +415,11 @@ namespace OpenSim.Region.DataSnapshot
|
||||
cli.RequestMethod = "GET";
|
||||
try
|
||||
{
|
||||
using(reply = cli.Request(null))
|
||||
// The notification response body is not used. Disposing the
|
||||
// response stream is sufficient; do not require a fixed
|
||||
// response length from third-party services.
|
||||
using (Stream reply = cli.Request(null))
|
||||
{
|
||||
byte[] response = new byte[1024];
|
||||
reply.Read(response, 0, 1024);
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException)
|
||||
@@ -433,7 +433,7 @@ namespace OpenSim.Region.DataSnapshot
|
||||
|
||||
// This is not quite working, so...
|
||||
// string responseStr = Util.UTF8.GetString(response);
|
||||
m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret);
|
||||
m_log.Info("[DATASNAPSHOT]: data service " + url + " notified.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,11 +88,11 @@ namespace OpenSim.Server.Handlers.Authentication
|
||||
return DoPlainMethods(body);
|
||||
|
||||
case "crypt":
|
||||
byte[] buffer = new byte[request.Length];
|
||||
long length = request.Length;
|
||||
if (length > 16384)
|
||||
length = 16384;
|
||||
request.Read(buffer, 0, (int)length);
|
||||
// Encrypted requests have a strict 16 KiB processing limit.
|
||||
// Allocate only the bytes that are actually consumed.
|
||||
int length = checked((int)Math.Min(request.Length, 16384L));
|
||||
byte[] buffer = new byte[length];
|
||||
request.ReadExactly(buffer);
|
||||
|
||||
return DoEncryptedMethods(buffer);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user