You've already forked lazarus-ccr
fpspreadsheet: Prevent biff8 reader crashing for a special file containing comboboxes (see forum http://forum.lazarus.freepascal.org/index.php/topic,29409.0.html).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4276 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -43,6 +43,7 @@ resourcestring
|
|||||||
rsWorksheetNotFound1 = 'Worksheet not found.';
|
rsWorksheetNotFound1 = 'Worksheet not found.';
|
||||||
rsInvalidWorksheetName = '"%s" is not a valid worksheet name.';
|
rsInvalidWorksheetName = '"%s" is not a valid worksheet name.';
|
||||||
rsDefectiveInternalStructure = 'Defective internal structure of %s file.';
|
rsDefectiveInternalStructure = 'Defective internal structure of %s file.';
|
||||||
|
rsFileStructureError = 'File structure error in %s record, position %d.';
|
||||||
rsUnknownDataType = 'Unknown data type.';
|
rsUnknownDataType = 'Unknown data type.';
|
||||||
rsUnknownErrorType = 'Unknown error type.';
|
rsUnknownErrorType = 'Unknown error type.';
|
||||||
rsTruncateTooLongCellText = 'Text value exceeds %d character limit in cell %s '+
|
rsTruncateTooLongCellText = 'Text value exceeds %d character limit in cell %s '+
|
||||||
|
@ -521,11 +521,13 @@ end;
|
|||||||
procedure TsSpreadBIFF8Reader.ReadOBJ(const AStream: TStream);
|
procedure TsSpreadBIFF8Reader.ReadOBJ(const AStream: TStream);
|
||||||
var
|
var
|
||||||
subrecID, subrecSize: Word;
|
subrecID, subrecSize: Word;
|
||||||
streamPos: Int64;
|
streamPos, p: Int64;
|
||||||
|
streamSize: Int64;
|
||||||
lastSubRec: Boolean;
|
lastSubRec: Boolean;
|
||||||
objType: Word;
|
objType: Word;
|
||||||
objID: Word;
|
objID: Word;
|
||||||
begin
|
begin
|
||||||
|
streamSize := AStream.Size;
|
||||||
lastSubRec := false;
|
lastSubRec := false;
|
||||||
while not lastSubRec do begin
|
while not lastSubRec do begin
|
||||||
subrecID := WordLEToN(AStream.ReadWord);
|
subrecID := WordLEToN(AStream.ReadWord);
|
||||||
@ -546,7 +548,13 @@ begin
|
|||||||
INT_EXCEL_OBJID_FTEND:
|
INT_EXCEL_OBJID_FTEND:
|
||||||
lastSubRec := true;
|
lastSubRec := true;
|
||||||
end;
|
end;
|
||||||
AStream.Position := streamPos + subrecSize;
|
p := streamPos + subrecSize;
|
||||||
|
if p < streamSize then
|
||||||
|
AStream.Position := p
|
||||||
|
else begin
|
||||||
|
FWorkbook.AddErrorMsg(Format(rsFileStructureError, ['OBJ', streamPos]));
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user