More -CriotR fixes:

* entfile.pas: Change PPU header falgs filed from longint to dword.
  * ngtcon.pas: Change local variable startoffset type to aword.
  * omfbase.pas: Avoid calling move with a nil string s indexed as s[1],
    to avoid a range check error.
  * owomflib.pas: Disable range check explicitly in hash computation.
  * utils/ppuutils/ppudump.pp: Adapt to flags type change in entfile.pas

git-svn-id: trunk@40163 -
This commit is contained in:
pierre 2018-11-01 21:58:54 +00:00
parent 59d5d6ec95
commit e49025a086
5 changed files with 30 additions and 16 deletions

View File

@ -196,8 +196,8 @@ type
compiler : word; compiler : word;
cpu : word; cpu : word;
target : word; target : word;
flags : longint; flags : dword;
size : longint; { size of the ppufile without header } size : dword; { size of the ppufile without header }
end; end;
pentryheader=^tentryheader; pentryheader=^tentryheader;

View File

@ -1522,7 +1522,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
bp : tbitpackedval; bp : tbitpackedval;
error, error,
is_packed: boolean; is_packed: boolean;
startoffset: aint; startoffset: aword;
procedure handle_stringconstn; procedure handle_stringconstn;
begin begin

View File

@ -1349,18 +1349,23 @@ implementation
internalerror(2015033103); internalerror(2015033103);
SetLength(s, len); SetLength(s, len);
UniqueString(s); UniqueString(s);
if len>0 then
Move(RawData[Offset+1],s[1],len); Move(RawData[Offset+1],s[1],len);
end; end;
function TOmfRawRecord.WriteStringAt(Offset: Integer; s: string): Integer; function TOmfRawRecord.WriteStringAt(Offset: Integer; s: string): Integer;
var
len : longint;
begin begin
if Length(s)>255 then len:=Length(s);
if len>255 then
internalerror(2015033101); internalerror(2015033101);
result:=Offset+Length(s)+1; result:=Offset+len+1;
if result>High(RawData) then if result>High(RawData) then
internalerror(2015033102); internalerror(2015033102);
RawData[Offset]:=Length(s); RawData[Offset]:=len;
Move(s[1], RawData[Offset+1], Length(s)); if len>0 then
Move(s[1], RawData[Offset+1], len);
end; end;
function TOmfRawRecord.ReadIndexedRef(Offset: Integer; out IndexedRef: Integer): Integer; function TOmfRawRecord.ReadIndexedRef(Offset: Integer; out IndexedRef: Integer): Integer;
@ -1420,7 +1425,7 @@ implementation
b:=0; b:=0;
for I:=-3 to RecordLength-2 do for I:=-3 to RecordLength-2 do
b:=byte(b+RawData[I]); b:=byte(b+RawData[I]);
SetChecksumByte($100-b); SetChecksumByte(byte($100-b));
end; end;
function TOmfRawRecord.VerifyChecksumByte: boolean; function TOmfRawRecord.VerifyChecksumByte: boolean;
@ -1521,14 +1526,18 @@ implementation
end; end;
procedure TOmfRecord_COMENT.EncodeTo(RawRecord: TOmfRawRecord); procedure TOmfRecord_COMENT.EncodeTo(RawRecord: TOmfRawRecord);
var
len : longint;
begin begin
RawRecord.RecordType:=RT_COMENT; RawRecord.RecordType:=RT_COMENT;
if (Length(FCommentString)+3)>High(RawRecord.RawData) then len:=Length(FCommentString);
if (len+3)>High(RawRecord.RawData) then
internalerror(2015033105); internalerror(2015033105);
RawRecord.RecordLength:=Length(FCommentString)+3; RawRecord.RecordLength:=len+3;
RawRecord.RawData[0]:=CommentType; RawRecord.RawData[0]:=CommentType;
RawRecord.RawData[1]:=CommentClass; RawRecord.RawData[1]:=CommentClass;
Move(FCommentString[1],RawRecord.RawData[2],Length(FCommentString)); if len>0 then
Move(FCommentString[1],RawRecord.RawData[2],len);
RawRecord.CalculateChecksumByte; RawRecord.CalculateChecksumByte;
end; end;

View File

@ -421,6 +421,9 @@ implementation
repeat repeat
pb:=@blocks[h.block_x]; pb:=@blocks[h.block_x];
success:=false; success:=false;
{$push}
{ Disable range check in that part of code }
{$R-}
repeat repeat
if pb^[h.bucket_x]=0 then if pb^[h.bucket_x]=0 then
begin begin
@ -440,6 +443,7 @@ implementation
end; end;
h.bucket_x:=(h.bucket_x+h.bucket_d) mod nbuckets; h.bucket_x:=(h.bucket_x+h.bucket_d) mod nbuckets;
until h.bucket_x=start_bucket; until h.bucket_x=start_bucket;
{$pop}
if not success then if not success then
begin begin
h.block_x:=(h.block_x+h.block_d) mod nblocks; h.block_x:=(h.block_x+h.block_d) mod nblocks;

View File

@ -545,10 +545,10 @@ begin
end; end;
function PPUFlags2Str(flags:longint):string; function PPUFlags2Str(flags:dword):string;
type type
tflagopt=record tflagopt=record
mask : longint; mask : dword;
str : string[30]; str : string[30];
end; end;
const const
@ -586,10 +586,11 @@ const
(mask: $10000000;str:'i8086_cs_equals_ds'), (mask: $10000000;str:'i8086_cs_equals_ds'),
(mask: $20000000;str:'package_deny'), (mask: $20000000;str:'package_deny'),
(mask: $40000000;str:'package_weak'), (mask: $40000000;str:'package_weak'),
(mask: longint($80000000);str:'i8086_ss_equals_ds') (mask: dword($80000000);str:'i8086_ss_equals_ds')
); );
var var
i,ntflags : longint; i : longint;
ntflags : dword;
first : boolean; first : boolean;
s : string; s : string;
begin begin