Browse Source

[Bug-61268] avoid NegativeArraySizeException parsing doc file

pull/1590/head
Antony Liu 1 month ago
parent
commit
101924bc9e
  1. 13
      main/DDF/UnknownEscherRecord.cs

13
main/DDF/UnknownEscherRecord.cs

@ -54,14 +54,14 @@ using Cysharp.Text;
int bytesRemaining = ReadHeader(data, offset);
/*
* Modified by Zhang Zhang
* Have a check between avaliable bytes and bytesRemaining,
* take the avaliable length if the bytesRemaining out of range.
* Have a check between available bytes and bytesRemaining,
* take the available length if the bytesRemaining out of range.
* July 09, 2010
*/
int avaliable = data.Length - (offset + 8);
if (bytesRemaining > avaliable)
int available = data.Length - (offset + 8);
if (bytesRemaining > available)
{
bytesRemaining = avaliable;
bytesRemaining = available;
}
if (IsContainerRecord)
{
@ -82,6 +82,9 @@ using Cysharp.Text;
}
else
{
if (bytesRemaining < 0) {
bytesRemaining = 0;
}
_thedata = new byte[bytesRemaining];
Array.Copy(data, offset + 8, _thedata, 0, bytesRemaining);
return bytesRemaining + 8;

Loading…
Cancel
Save