Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions main/HSSF/Record/HeaderFooterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ limitations under the License.
namespace NPOI.HSSF.Record
{
using System;
using NPOI.Util;
using NPOI.Util;

/**
* Common header/footer base class
*
* @author Josh Micich
*/
/**
* Common header/footer base class
*
* @author Josh Micich
*/
public abstract class HeaderFooterBase : StandardRecord
{
private bool field_2_hasMultibyte;
Expand All @@ -40,6 +40,15 @@ protected HeaderFooterBase(RecordInputStream in1)
if (in1.Remaining > 0)
{
int field_1_footer_len = in1.ReadShort();
//61287 -- if the footer_len == 0, there may not be a multibyte flag
if (field_1_footer_len == 0)
{
field_3_text = "";
if (in1.Remaining == 0)
{
return;
}
}
field_2_hasMultibyte = in1.ReadByte() != 0x00;

if (field_2_hasMultibyte)
Expand Down
5 changes: 4 additions & 1 deletion main/HSSF/Record/WriteProtectRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ public WriteProtectRecord()

public WriteProtectRecord(RecordInputStream in1)
{

if (in1.Remaining == 2)
{
in1.ReadShort();
}
}

public override String ToString()
Expand Down
8 changes: 8 additions & 0 deletions main/POIFS/FileSystem/NDocumentInputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public NDocumentInputStream(DocumentEntry document)
_marked_offset_count = 0;
_document_size = document.Size;
_closed = false;
if (_document_size < 0)
{
// throw new RecordFormatException("document_size cannot be < 0");
}

DocumentProperty property = (DocumentProperty)doc.Property;
_document = new NPOIFSDocument(
Expand Down Expand Up @@ -277,6 +281,10 @@ private void CheckAvaliable(int requestedSize)

public override void ReadFully(byte[] buf, int off, int len)
{
if (len < 0)
{
throw new RuntimeException("Can't read negative number of bytes");
}
CheckAvaliable(len);

int read = 0;
Expand Down
5 changes: 5 additions & 0 deletions main/POIFS/FileSystem/ODocumentInputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
using System;
using NPOI.POIFS.Storage;
using System.IO;
using NPOI.Util;

namespace NPOI.POIFS.FileSystem
{
Expand Down Expand Up @@ -71,6 +72,10 @@ public ODocumentInputStream(DocumentEntry document)
_current_offset = 0;
_marked_offset = 0;
_document_size = document.Size;
if (_document_size < 0)
{
throw new RecordFormatException("document_size cannot be < 0");
}
_closed = false;
_document = documentNode.Document;
_currentBlock = GetDataInputBlock(0);
Expand Down
Loading
Loading