Merge commits 39912, 39914, 40001, 40115, 40132 and 40163

------------------------------------------------------------------------
r39912 | pierre | 2018-10-11 22:38:39 +0200 (Thu, 11 Oct 2018) | 1 line

 Fix ppuload for string type for i8086, use getasizeint for all string defs but short string
------------------------------------------------------------------------
------------------------------------------------------------------------
r39914 | pierre | 2018-10-12 08:05:50 +0200 (Fri, 12 Oct 2018) | 1 line

 Adapt ppudump to fix introduced in revision 39912
------------------------------------------------------------------------
------------------------------------------------------------------------
r40001 | pierre | 2018-10-21 00:19:08 +0200 (Sun, 21 Oct 2018) | 1 line

 Add explicit typecast to avoid range check error
------------------------------------------------------------------------
------------------------------------------------------------------------
r40115 | pierre | 2018-10-31 23:53:11 +0100 (Wed, 31 Oct 2018) | 1 line

 Avoid range check error in ReadPosInfo
------------------------------------------------------------------------
------------------------------------------------------------------------
r40132 | pierre | 2018-11-01 08:09:47 +0100 (Thu, 01 Nov 2018) | 1 line

 Only call moved if len>0, as otherwise astring local variable is nil, which leads to a range check error for astring[1]
------------------------------------------------------------------------
------------------------------------------------------------------------
r40163 | pierre | 2018-11-01 22:58:54 +0100 (Thu, 01 Nov 2018) | 8 lines

  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: branches/fixes_3_2@40519 -
This commit is contained in:
pierre 2018-12-10 21:18:24 +00:00
parent 36f9ce1cb2
commit 6205e530aa
6 changed files with 42 additions and 27 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -2421,7 +2421,7 @@ implementation
begin
inherited ppuload(stringdef,ppufile);
stringtype:=st_ansistring;
len:=ppufile.getaint;
len:=ppufile.getasizeint;
encoding:=ppufile.getword;
ppuload_platform(ppufile);
end;
@ -2447,7 +2447,7 @@ implementation
encoding:=CP_UTF16LE
else
encoding:=CP_UTF16BE;
len:=ppufile.getaint;
len:=ppufile.getasizeint;
ppuload_platform(ppufile);
end;
@ -2468,7 +2468,7 @@ implementation
begin
inherited ppuload(stringdef,ppufile);
stringtype:=st_unicodestring;
len:=ppufile.getaint;
len:=ppufile.getasizeint;
encoding:=ppufile.getword;
ppuload_platform(ppufile);
end;
@ -2505,7 +2505,7 @@ implementation
ppufile.putbyte(byte(len))
end
else
ppufile.putaint(len);
ppufile.putasizeint(len);
if stringtype in [st_ansistring,st_unicodestring] then
ppufile.putword(encoding);
case stringtype of

View File

@ -537,10 +537,10 @@ begin
end;
function PPUFlags2Str(flags:longint):string;
function PPUFlags2Str(flags:dword):string;
type
tflagopt=record
mask : longint;
mask : dword;
str : string[30];
end;
const
@ -578,10 +578,11 @@ const
(mask: $10000000;str:'i8086_cs_equals_ds'),
(mask: $20000000;str:'package_deny'),
(mask: $40000000;str:'package_weak'),
(mask: longint($80000000);str:'i8086_ss_equals_ds')
(mask: dword($80000000);str:'i8086_ss_equals_ds')
);
var
i,ntflags : longint;
i : longint;
ntflags : dword;
first : boolean;
s : string;
begin
@ -1051,7 +1052,7 @@ begin
Writeln([fileindex,' (',line,',',column,')']);
if Def <> nil then
begin
Def.FilePos.FileIndex:=fileindex - 1;
Def.FilePos.FileIndex:=fileindex;
Def.FilePos.Line:=line;
Def.FilePos.Col:=column;
end;
@ -1812,7 +1813,8 @@ begin
begin
len:=gettokenbufsizeint;
setlength(astring,len);
move(tokenbuf[tbi],astring[1],len);
if len>0 then
move(tokenbuf[tbi],astring[1],len);
write([' ',astring]);
inc(tbi,len);
end;
@ -2595,7 +2597,7 @@ begin
write ([space,' PointerType : ']);
readderef('',constdef.TypeRef);
constdef.ConstType:=ctInt;
constdef.VInt:=getptruint;
constdef.VInt:=int64(getptruint);
writeln([space,' Value : ',constdef.VInt])
end;
conststring,
@ -3306,7 +3308,7 @@ begin
strdef:=TPpuStringDef.Create(ParentDef);
strdef.StrType:=stWide;
readcommondef('WideString definition',defoptions,strdef);
strdef.Len:=getaint;
strdef.Len:=getasizeint;
writeln([space,' Length : ',strdef.Len]);
end;
@ -3315,7 +3317,7 @@ begin
strdef:=TPpuStringDef.Create(ParentDef);
strdef.StrType:=stUnicode;
readcommondef('UnicodeString definition',defoptions,strdef);
strdef.Len:=getaint;
strdef.Len:=getasizeint;
writeln([space,' Length : ',strdef.Len]);
writeln([space,' Encoding : ',getword]);
end;
@ -3325,7 +3327,7 @@ begin
strdef:=TPpuStringDef.Create(ParentDef);
strdef.StrType:=stAnsi;
readcommondef('AnsiString definition',defoptions,strdef);
strdef.Len:=getaint;
strdef.Len:=getasizeint;
writeln([space,' Length : ',strdef.Len]);
writeln([space,' Encoding : ',getword]);
end;
@ -3335,7 +3337,7 @@ begin
strdef:=TPpuStringDef.Create(ParentDef);
strdef.StrType:=stLong;
readcommondef('Longstring definition',defoptions,strdef);
strdef.Len:=getaint;
strdef.Len:=getasizeint;
writeln([space,' Length : ',strdef.Len]);
end;