mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 17:49:25 +02:00
* fixed generic index- and comparebyte/word/dword for limits which
overflow the pointer range (fixes tw3612 regression on sparc/solaris) git-svn-id: trunk@8754 -
This commit is contained in:
parent
d40293b7fb
commit
b5a1a6c6b4
@ -241,7 +241,8 @@ begin
|
|||||||
psrc:=@buf;
|
psrc:=@buf;
|
||||||
{ simulate assembler implementations behaviour, which is expected }
|
{ simulate assembler implementations behaviour, which is expected }
|
||||||
{ fpc_pchar_to_ansistr in astrings.inc }
|
{ fpc_pchar_to_ansistr in astrings.inc }
|
||||||
if (len < 0) then
|
if (len < 0) or
|
||||||
|
(psrc+len < psrc) then
|
||||||
pend:=pbyte(high(PtrUInt)-sizeof(byte))
|
pend:=pbyte(high(PtrUInt)-sizeof(byte))
|
||||||
else
|
else
|
||||||
pend:=psrc+len;
|
pend:=psrc+len;
|
||||||
@ -267,7 +268,9 @@ begin
|
|||||||
psrc:=@buf;
|
psrc:=@buf;
|
||||||
{ simulate assembler implementations behaviour, which is expected }
|
{ simulate assembler implementations behaviour, which is expected }
|
||||||
{ fpc_pchar_to_ansistr in astrings.inc }
|
{ fpc_pchar_to_ansistr in astrings.inc }
|
||||||
if (len < 0) then
|
if (len < 0) or
|
||||||
|
(len > high(PtrUInt) div 2) or
|
||||||
|
(psrc+len < psrc) then
|
||||||
pend:=pword(high(PtrUInt)-sizeof(word))
|
pend:=pword(high(PtrUInt)-sizeof(word))
|
||||||
else
|
else
|
||||||
pend:=psrc+len;
|
pend:=psrc+len;
|
||||||
@ -293,7 +296,9 @@ begin
|
|||||||
psrc:=@buf;
|
psrc:=@buf;
|
||||||
{ simulate assembler implementations behaviour, which is expected }
|
{ simulate assembler implementations behaviour, which is expected }
|
||||||
{ fpc_pchar_to_ansistr in astrings.inc }
|
{ fpc_pchar_to_ansistr in astrings.inc }
|
||||||
if (len < 0) then
|
if (len < 0) or
|
||||||
|
(len > high(PtrUInt) div 4) or
|
||||||
|
(psrc+len < psrc) then
|
||||||
pend:=pdword(high(PtrUInt)-sizeof(dword))
|
pend:=pdword(high(PtrUInt)-sizeof(dword))
|
||||||
else
|
else
|
||||||
pend:=psrc+len;
|
pend:=psrc+len;
|
||||||
@ -355,7 +360,10 @@ begin
|
|||||||
inc(pptruint(psrc));
|
inc(pptruint(psrc));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
pend:=psrc+len;
|
if (psrc+len > psrc) then
|
||||||
|
pend:=psrc+len
|
||||||
|
else
|
||||||
|
pend:=pbyte(high(ptruint)-1);
|
||||||
while psrc<pend do
|
while psrc<pend do
|
||||||
begin
|
begin
|
||||||
b:=(ptrint(psrc^)-ptrint(pdest^));
|
b:=(ptrint(psrc^)-ptrint(pdest^));
|
||||||
@ -418,7 +426,11 @@ begin
|
|||||||
inc(pptruint(psrc));
|
inc(pptruint(psrc));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
pend:=psrc+len;
|
if (len <= high(ptruint) div 2) and
|
||||||
|
(psrc+len > psrc) then
|
||||||
|
pend:=psrc+len
|
||||||
|
else
|
||||||
|
pend:=pword(high(ptruint)-2);
|
||||||
while psrc<pend do
|
while psrc<pend do
|
||||||
begin
|
begin
|
||||||
b:=(ptrint(psrc^)-ptrint(pdest^));
|
b:=(ptrint(psrc^)-ptrint(pdest^));
|
||||||
@ -481,7 +493,11 @@ begin
|
|||||||
inc(pptruint(psrc));
|
inc(pptruint(psrc));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
pend:=psrc+len;
|
if (len <= high(ptruint) div 4) and
|
||||||
|
(psrc+len > psrc) then
|
||||||
|
pend:=psrc+len
|
||||||
|
else
|
||||||
|
pend:=pdword(high(ptruint)-4);
|
||||||
while psrc<pend do
|
while psrc<pend do
|
||||||
begin
|
begin
|
||||||
b:=(ptrint(psrc^)-ptrint(pdest^));
|
b:=(ptrint(psrc^)-ptrint(pdest^));
|
||||||
|
Loading…
Reference in New Issue
Block a user